use of com.ibm.dtfj.java.JavaObject in project openj9 by eclipse.
the class DTFJJavaObject method getAssociatedClass.
private JavaClass getAssociatedClass() {
// Retrieve the class loader for this class for using introspection to speed up
// lookup when lots of classes are loaded by lots of class loaders.
JavaObject targetClassLoaderObject = null;
try {
JavaClass javaLangClass = this.getJavaClass();
Iterator<?> fields = javaLangClass.getDeclaredFields();
while (fields.hasNext()) {
Object o = fields.next();
if (o instanceof JavaField) {
JavaField field = (JavaField) o;
if ("classLoader".equals(field.getName())) {
targetClassLoaderObject = (JavaObject) field.get(this);
break;
}
}
}
} catch (CorruptDataException e) {
// This is only an optimisation to save us walking all class loaders. Continue
} catch (MemoryAccessException e) {
// This is only an optimisation to save us walking all class loaders. Continue
}
return getAssociatedClass(targetClassLoaderObject);
}
use of com.ibm.dtfj.java.JavaObject in project openj9 by eclipse.
the class DTFJJavaObject method addAllObjectArrayReferences.
private void addAllObjectArrayReferences() throws CorruptDataException, MemoryAccessException {
getReferences();
JavaObject[] elements = new JavaObject[arraySize];
this.arraycopy(0, elements, 0, arraySize);
for (int i = 0; i != elements.length; i++) {
JavaObject thisObj = elements[i];
if (thisObj != null) {
references.add(new DTFJJavaReference(this, thisObj, "Array Reference [" + i + "]", JavaReference.REFERENCE_ARRAY_ELEMENT, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG));
}
}
}
use of com.ibm.dtfj.java.JavaObject in project openj9 by eclipse.
the class DTFJJavaClass method addConstantPoolReferences.
@SuppressWarnings("rawtypes")
private JavaReference addConstantPoolReferences(List<Object> references) {
// get the Constant Pool references from this class.
JavaReference jRef = null;
Iterator constantPoolIt = getConstantPoolReferences();
try {
while (constantPoolIt.hasNext()) {
// get each reference in turn, note that the iterator can return JavaClass
// JavaObject and CorruptData. The CorruptData objects are ignored.
Object cpObject = constantPoolIt.next();
if (cpObject instanceof JavaObject) {
// add the reference to the container.
jRef = new DTFJJavaReference(this, cpObject, "Constant Pool Object", JavaReference.REFERENCE_CONSTANT_POOL, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
} else if (cpObject instanceof JavaClass) {
// add the reference to the container.
jRef = new DTFJJavaReference(this, cpObject, "Constant Pool Class", JavaReference.REFERENCE_CONSTANT_POOL, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
}
if (null != jRef) {
references.add(jRef);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
references.add(cd);
}
return jRef;
}
use of com.ibm.dtfj.java.JavaObject in project openj9 by eclipse.
the class DTFJJavaThread method getObject.
/* (non-Javadoc)
* @see com.ibm.dtfj.java.JavaThread#getObject()
*/
public JavaObject getObject() throws CorruptDataException {
try {
if (thread.threadObject().isNull()) {
return null;
} else {
JavaObject threadObj = new DTFJJavaObject(thread.threadObject());
// For additional validation of the java.lang.Thread object try getting its class name
threadObj.getJavaClass().getName();
return threadObj;
}
} catch (Throwable t) {
throw J9DDRDTFJUtils.handleAsCorruptDataException(DTFJContext.getProcess(), t);
}
}
use of com.ibm.dtfj.java.JavaObject in project openj9 by eclipse.
the class JavaObjectComparator method testArraySize.
@SuppressWarnings("unchecked")
public void testArraySize(List ddrObjects, List jextractObjects) throws Exception {
assertEquals(jextractObjects.size(), ddrObjects.size());
for (int i = 0; i < ddrObjects.size(); i++) {
JavaObject ddrJavaObject = (JavaObject) ddrObjects.get(i);
JavaObject jextractJavaObject = (JavaObject) jextractObjects.get(i);
if (ddrJavaObject.isArray() == jextractJavaObject.isArray()) {
int ddrSize = 0;
try {
ddrSize = ddrJavaObject.getArraySize();
} catch (IllegalArgumentException e) {
if (ddrJavaObject.isArray()) {
throw e;
}
}
int jextractSize = 0;
try {
jextractSize = jextractJavaObject.getArraySize();
} catch (IllegalArgumentException e) {
if (jextractJavaObject.isArray()) {
throw e;
}
}
assertEquals("ddr array size not equal to jextract array size", jextractSize, ddrSize);
}
}
}
Aggregations