Search in sources :

Example 6 with JavaObject

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);
}
Also used : JavaField(com.ibm.dtfj.java.JavaField) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 7 with JavaObject

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));
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject)

Example 8 with JavaObject

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;
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) J9ObjectFieldOffsetIterator(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffsetIterator) DTFJConstantPoolIterator(com.ibm.j9ddr.vm29.view.dtfj.java.j9.DTFJConstantPoolIterator) J9DDRDTFJUtils.corruptIterator(com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Example 9 with JavaObject

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);
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject)

Example 10 with JavaObject

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);
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject)

Aggregations

JavaObject (com.ibm.dtfj.java.JavaObject)70 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)47 Iterator (java.util.Iterator)35 JavaClass (com.ibm.dtfj.java.JavaClass)31 CorruptData (com.ibm.dtfj.image.CorruptData)19 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)17 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)14 JavaReference (com.ibm.dtfj.java.JavaReference)9 JavaThread (com.ibm.dtfj.java.JavaThread)9 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)8 JavaField (com.ibm.dtfj.java.JavaField)7 ImagePointer (com.ibm.dtfj.image.ImagePointer)6 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)6 J9Object (com.ibm.j9ddr.vm29.structure.J9Object)6 CorruptJavaObject (com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject)6 CorruptData (com.ibm.dtfj.image.j9.CorruptData)5 LongEnumeration (com.ibm.dtfj.phd.util.LongEnumeration)5 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)5 LongListReferenceIterator (com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator)5 ReferenceIterator (com.ibm.jvm.dtfjview.heapdump.ReferenceIterator)5