use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class InfoClassCommand method printClassDetails.
private void printClassDetails(JavaRuntime jr, String className, JavaClass jc) {
String spaces = " ";
String cdeInfo = "N/A (CorruptDataException occurred)";
try {
out.print("name = " + jc.getName());
} catch (CorruptDataException dce) {
out.print("name = " + cdeInfo);
}
out.print("\n\n\t");
out.print("ID = " + Utils.toHex(jc.getID()));
String superClassId;
try {
JavaClass superClass = jc.getSuperclass();
if (null == superClass) {
superClassId = "<no superclass>";
} else {
superClassId = Utils.toHex(superClass.getID());
}
} catch (CorruptDataException dce) {
superClassId = cdeInfo;
}
out.print(spaces);
out.print("superID = " + superClassId);
// Omitting size of class because that might differ between instances (i.e. arrays)
String classLoaderId;
try {
JavaClassLoader jClassLoader = jc.getClassLoader();
JavaObject jo = jClassLoader.getObject();
if (jo != null) {
classLoaderId = Utils.toHex(jo.getID());
} else {
classLoaderId = "<data unavailable>";
}
} catch (CorruptDataException cde) {
classLoaderId = cdeInfo;
}
out.print(spaces);
out.print("\n\t");
out.print("classLoader = " + classLoaderId);
String modifiersInfo;
try {
modifiersInfo = Utils.getClassModifierString(jc);
} catch (CorruptDataException cde) {
modifiersInfo = cdeInfo;
}
out.print(spaces);
out.print("modifiers: " + modifiersInfo);
out.print("\n\n");
ClassStatistics d = getClassStatisticsFor(jr, jc);
out.print("\tnumber of instances: " + d.getCount() + "\n");
out.print("\ttotal size of instances on the heap: " + d.getSize() + " bytes");
out.print("\n\n");
printClassHierarchy(jc);
out.print("\n");
printFields(jc);
out.print("\n");
printMethods(jc);
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class PHDJavaRuntime method prepClassLoaders.
/**
* Remember objects associated with class loaders
* Performance optimization - we can then find these objects on a scan through the heap
* and remember them, saving a fruitless search of the heap if they only exist in a javacore.
*/
private void prepClassLoaders() {
if (metaJavaRuntime != null) {
final PHDJavaClassLoader boot = loaders.get(null);
for (Iterator it = metaJavaRuntime.getJavaClassLoaders(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof CorruptData)
continue;
JavaClassLoader load = (JavaClassLoader) next;
try {
JavaObject jo = load.getObject();
saveExtraObject(boot, jo);
} catch (CorruptDataException e) {
}
}
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class Utils method getClassGivenName.
public static JavaClass[] getClassGivenName(String className, JavaRuntime jr, PrintStream out) {
Iterator itJavaClassLoader = jr.getJavaClassLoaders();
List classes = new ArrayList();
while (itJavaClassLoader.hasNext()) {
Object nextCl = itJavaClassLoader.next();
if (!(nextCl instanceof JavaClassLoader)) {
continue;
}
JavaClassLoader jcl = (JavaClassLoader) nextCl;
Iterator itJavaClass = jcl.getDefinedClasses();
while (itJavaClass.hasNext()) {
Object next = itJavaClass.next();
if (!(next instanceof JavaClass)) {
continue;
}
JavaClass jc = (JavaClass) next;
String currClassName;
try {
currClassName = jc.getName();
if (currClassName.equals(className)) {
classes.add(jc);
}
} catch (CorruptDataException e) {
out.print("\t <error getting class name while traversing classes: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
currClassName = null;
}
}
}
if (classes.size() > 0) {
return (JavaClass[]) classes.toArray(new JavaClass[0]);
} else {
return null;
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class Utils method getClassGivenAddress.
public static JavaClass getClassGivenAddress(long address, JavaRuntime jr) {
Iterator itJavaClassLoader = jr.getJavaClassLoaders();
while (itJavaClassLoader.hasNext()) {
Object nextCl = itJavaClassLoader.next();
if (!(nextCl instanceof JavaClassLoader)) {
continue;
}
JavaClassLoader jcl = (JavaClassLoader) nextCl;
Iterator itJavaClass = jcl.getDefinedClasses();
while (itJavaClass.hasNext()) {
Object next = itJavaClass.next();
if (!(next instanceof JavaClass)) {
continue;
}
if (next instanceof JavaClass) {
JavaClass jc = (JavaClass) next;
long currClassAddress = jc.getID().getAddress();
if (currClassAddress == address) {
return jc;
}
}
}
}
return null;
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class JavaFieldTest 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.getDeclaredFields(), jextractObjects, jextractClass.getDeclaredFields(), JavaClassTest.DECLARED_FIELDS_SORT_ORDER);
}
}
Aggregations