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");
}
}
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");
}
Aggregations