use of com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator in project openj9 by eclipse.
the class HeapdumpCommand method getClassReferences.
/* Reference code reimplemented (rather than using the DTFJ getReferences() API)
* because we are trying to match the behaviour of the runtime heapdump rather than
* the GC spec. The set of references we're trying to create is different.
*/
/**
* Gets the references for the supplied class
*
* @param thisJavaClass Class being examined
*/
private ReferenceIterator getClassReferences(JavaClass thisJavaClass) {
List references = new LinkedList();
try {
// Class object instance references
addReferences(thisJavaClass.getObject(), references);
// Statics
addStaticReferences(thisJavaClass, references);
addProtectionDomainReference(thisJavaClass, references);
// Constant pool class references
Iterator constantPoolIt = thisJavaClass.getConstantPoolReferences();
while (constantPoolIt.hasNext()) {
Object cpObject = constantPoolIt.next();
if (cpObject instanceof JavaClass) {
// Found a class reference, add it to the list
JavaClass cpJavaClass = (JavaClass) cpObject;
references.add(new Long(cpJavaClass.getObject().getID().getAddress()));
}
}
// Superclass references
JavaClass superClass = thisJavaClass.getSuperclass();
while (null != superClass) {
references.add(new Long(superClass.getObject().getID().getAddress()));
superClass = superClass.getSuperclass();
}
// Classloader
JavaClassLoader loader = thisJavaClass.getClassLoader();
if (loader != null) {
JavaObject loaderObject = loader.getObject();
if (loaderObject != null) {
references.add(new Long(loaderObject.getID().getAddress()));
} else {
reportError("Null loader object returned for class: " + thisJavaClass.getName() + "(" + thisJavaClass.getID() + ")", null);
_numberOfErrors++;
}
} else {
reportError("Null classloader returned for class: " + thisJavaClass.getName() + "(" + thisJavaClass.getID() + ")", null);
_numberOfErrors++;
}
} catch (DTFJException ex) {
reportError(null, ex);
_numberOfErrors++;
}
return new LongListReferenceIterator(references);
}
Aggregations