use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class JavaClassLoaderTest method findClassTest.
@SuppressWarnings("unchecked")
@Test
public void findClassTest() throws Exception {
JavaClassComparator comparator = new JavaClassComparator();
assertEquals(jextractTestObjects.size(), ddrTestObjects.size());
for (int i = 0; i < ddrTestObjects.size(); i++) {
JavaClassLoader ddrLoader = (JavaClassLoader) ddrTestObjects.get(i);
JavaClassLoader jextractLoader = (JavaClassLoader) jextractTestObjects.get(i);
Iterator ddrClasses = ddrLoader.getDefinedClasses();
// loop the defined classes trying to find each one
Iterator jextractClasses = jextractLoader.getDefinedClasses();
while (ddrClasses.hasNext() || jextractClasses.hasNext()) {
assertTrue("DDR classloader has less items than the jextract equivalent : " + ddrLoader.toString(), ddrClasses.hasNext());
assertTrue("Jextract classloader has less items than the jextract equivalent : " + jextractLoader.toString(), jextractClasses.hasNext());
JavaClass ddrClass = (JavaClass) ddrClasses.next();
JavaClass jextractClass = (JavaClass) jextractClasses.next();
assertEquals("Different class names : ddr = " + ddrClass.getName() + " jx = " + jextractClass.getName(), jextractClass.getName(), ddrClass.getName());
String name = ddrClass.getName();
JavaClass ddrFound = ddrLoader.findClass(name);
assertNotNull("DDR loader could not find class : " + name, ddrFound);
JavaClass jextractFound = jextractLoader.findClass(name);
assertNotNull("JX loader could not find class : " + name, jextractFound);
comparator.testEquals(ddrFound, jextractFound, javaClassComparator.getDefaultMask());
}
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class JavaClassTest method loadTestObjects.
protected void loadTestObjects(JavaRuntime ddrRuntime, List<Object> ddrObjects, JavaRuntime jextractRuntime, List<Object> jextractObjects) {
List<Object> ddrClassLoaders = new ArrayList<Object>();
List<Object> jextractClassLoaders = new ArrayList<Object>();
fillLists(ddrClassLoaders, ddrRuntime.getJavaClassLoaders(), jextractClassLoaders, jextractRuntime.getJavaClassLoaders(), null);
for (int i = 0; i < ddrClassLoaders.size(); i++) {
JavaClassLoader ddrClassLoader = (JavaClassLoader) ddrClassLoaders.get(i);
JavaClassLoader jextractClassLoader = (JavaClassLoader) jextractClassLoaders.get(i);
fillLists(ddrObjects, ddrClassLoader.getDefinedClasses(), jextractObjects, jextractClassLoader.getDefinedClasses(), null);
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class ImagePointerTest method loadTestObjects.
protected void loadTestObjects(JavaRuntime ddrRuntime, List<Object> ddrObjects, JavaRuntime jextractRuntime, List<Object> jextractObjects) {
List<Object> ddrClassLoaders = new ArrayList<Object>();
List<Object> jextractClassLoaders = new ArrayList<Object>();
fillLists(ddrClassLoaders, ddrRuntime.getJavaClassLoaders(), jextractClassLoaders, jextractRuntime.getJavaClassLoaders(), null);
for (int i = 0; i < ddrClassLoaders.size(); i++) {
JavaClassLoader ddrClassLoader = (JavaClassLoader) ddrClassLoaders.get(i);
JavaClassLoader jextractClassLoader = (JavaClassLoader) jextractClassLoaders.get(i);
try {
ddrObjects.add(ddrClassLoader.getObject().getID());
jextractObjects.add(jextractClassLoader.getObject().getID());
} catch (CorruptDataException e) {
fail("Problem initializing test");
}
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class JavaMethodTest method loadTestObjects.
protected void loadTestObjects(JavaRuntime ddrRuntime, List<Object> ddrObjects, JavaRuntime jextractRuntime, List<Object> jextractObjects) {
List<Object> ddrClassLoaders = new ArrayList<Object>();
List<Object> jextractClassLoaders = new ArrayList<Object>();
fillLists(ddrClassLoaders, ddrRuntime.getJavaClassLoaders(), jextractClassLoaders, jextractRuntime.getJavaClassLoaders(), null);
List<Object> ddrClasses = new ArrayList<Object>();
List<Object> jextractClasses = new ArrayList<Object>();
for (int i = 0; i < ddrClassLoaders.size(); i++) {
JavaClassLoader ddrClassLoader = (JavaClassLoader) ddrClassLoaders.get(i);
JavaClassLoader jextractClassLoader = (JavaClassLoader) jextractClassLoaders.get(i);
fillLists(ddrClasses, ddrClassLoader.getDefinedClasses(), jextractClasses, jextractClassLoader.getDefinedClasses(), null);
}
for (int i = 0; i < ddrClasses.size(); i++) {
JavaClass ddrClass = (JavaClass) ddrClasses.get(i);
JavaClass jextractClass = (JavaClass) jextractClasses.get(i);
fillLists(ddrObjects, ddrClass.getDeclaredMethods(), jextractObjects, jextractClass.getDeclaredMethods(), null);
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class JavaAbstractClass method addClassLoaderReference.
protected void addClassLoaderReference(Collection coll) {
JavaReference jRef = null;
try {
JavaClassLoader classLoader = this.getClassLoader();
if (null != classLoader) {
JavaObject classLoaderObject = classLoader.getObject();
if (null != classLoaderObject) {
jRef = new JavaReference(_javaVM, this, classLoaderObject, "Classloader", JavaReference.REFERENCE_CLASS_LOADER, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
coll.add(jRef);
}
}
} catch (CorruptDataException e) {
coll.add(e.getCorruptData());
}
}
Aggregations