Search in sources :

Example 21 with JavaClassLoader

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());
        }
    }
}
Also used : JavaClassComparator(com.ibm.j9ddr.view.dtfj.comparators.JavaClassComparator) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 22 with JavaClassLoader

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);
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) ArrayList(java.util.ArrayList) JavaObject(com.ibm.dtfj.java.JavaObject)

Example 23 with JavaClassLoader

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");
        }
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) ArrayList(java.util.ArrayList) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 24 with JavaClassLoader

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);
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) ArrayList(java.util.ArrayList)

Example 25 with JavaClassLoader

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());
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Aggregations

JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)32 JavaClass (com.ibm.dtfj.java.JavaClass)24 Iterator (java.util.Iterator)16 JavaObject (com.ibm.dtfj.java.JavaObject)15 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)14 ArrayList (java.util.ArrayList)7 CorruptData (com.ibm.dtfj.image.CorruptData)6 JavaReference (com.ibm.dtfj.java.JavaReference)3 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)3 List (java.util.List)3 DTFJException (com.ibm.dtfj.image.DTFJException)2 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 ImagePointer (com.ibm.dtfj.image.ImagePointer)2 JavaMethod (com.ibm.dtfj.java.JavaMethod)2 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)2 PortableHeapDumpListener (com.ibm.dtfj.phd.parser.PortableHeapDumpListener)2 LongEnumeration (com.ibm.dtfj.phd.util.LongEnumeration)2 J9DDRDTFJUtils.corruptIterator (com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator)2 J9Object (com.ibm.j9ddr.vm29.structure.J9Object)2 CorruptJavaObject (com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject)2