Search in sources :

Example 31 with JavaClassLoader

use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.

the class InfoClassCommand method cacheRuntimeClasses.

/**
 * Pre-populates the classInstanceCounts map with just classes, and empty ClassStatistics objects.
 * The key-set of classInstanceCounts.get(someRuntime) can be then treated as a cache of all classes for that runtime,
 * eliminating the need to iterate over all class loaders (see getRuntimeClasses()).
 * @param jr
 * @param errOut
 * @return
 */
private void cacheRuntimeClasses() {
    classInstanceCounts = new HashMap<JavaRuntime, Map<JavaClass, ClassStatistics>>();
    long corruptClassCount = 0;
    Map<JavaClass, ClassStatistics> classesOfThisRuntime = new HashMap<JavaClass, ClassStatistics>();
    JavaRuntime runtime = ctx.getRuntime();
    classInstanceCounts.put(runtime, classesOfThisRuntime);
    Iterator itClassLoader = runtime.getJavaClassLoaders();
    while (itClassLoader.hasNext()) {
        JavaClassLoader jcl = (JavaClassLoader) itClassLoader.next();
        Iterator itClass = jcl.getDefinedClasses();
        while (itClass.hasNext()) {
            Object obj = itClass.next();
            if (obj instanceof JavaClass) {
                // check that a cast can be made to JavaClass
                classesOfThisRuntime.put((JavaClass) obj, new ClassStatistics());
            } else {
                corruptClassCount++;
            }
        }
    }
    if (corruptClassCount > 0) {
        out.print("Warning, found " + corruptClassCount + " corrupt classes during classloader walk\n");
    }
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaClass(com.ibm.dtfj.java.JavaClass) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) HashMap(java.util.HashMap) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 32 with JavaClassLoader

use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.

the class InfoJitmCommand method showJITdMethods.

private void showJITdMethods() {
    JavaRuntime jr = ctx.getRuntime();
    Iterator itJavaClassLoader = jr.getJavaClassLoaders();
    while (itJavaClassLoader.hasNext()) {
        JavaClassLoader jcl = (JavaClassLoader) itJavaClassLoader.next();
        Iterator itJavaClass = jcl.getDefinedClasses();
        while (itJavaClass.hasNext()) {
            JavaClass jc = (JavaClass) itJavaClass.next();
            Iterator itJavaMethod = jc.getDeclaredMethods();
            String jcName;
            try {
                jcName = jc.getName();
            } catch (CorruptDataException e) {
                jcName = Exceptions.getCorruptDataExceptionString();
            }
            while (itJavaMethod.hasNext()) {
                JavaMethod jm = (JavaMethod) itJavaMethod.next();
                String name;
                String sig;
                try {
                    name = jm.getName();
                } catch (CorruptDataException e) {
                    name = Exceptions.getCorruptDataExceptionString();
                }
                try {
                    sig = jm.getSignature();
                } catch (CorruptDataException e) {
                    sig = Exceptions.getCorruptDataExceptionString();
                }
                if (jm.getCompiledSections().hasNext()) {
                    Iterator itImageSection = jm.getCompiledSections();
                    while (itImageSection.hasNext()) {
                        ImageSection is = (ImageSection) itImageSection.next();
                        long startAddr = is.getBaseAddress().getAddress();
                        long size = is.getSize();
                        long endAddr = startAddr + size;
                        out.print("\n\t" + "start=" + Utils.toHex(startAddr) + "  " + "end=" + Utils.toHex(endAddr) + "   " + jcName + "::" + name + sig);
                    }
                }
            }
        }
    }
    out.print("\n");
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) JavaMethod(com.ibm.dtfj.java.JavaMethod) ImageSection(com.ibm.dtfj.image.ImageSection) 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