Search in sources :

Example 6 with JavaReference

use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.

the class JavaReferenceComparator method testEquals.

// getDescription
// getReachability
// getReferenceType
// getRootType
// getSource
// getTarget
// isClassReference
// isObjectReference
public void testEquals(Object ddrObject, Object jextractObject, int members) {
    JavaReference ddrJavaReference = (JavaReference) ddrObject;
    JavaReference jextractJavaReference = (JavaReference) jextractObject;
    // getDescription
    if ((DESCRIPTION & members) != 0)
        testJavaEquals(ddrJavaReference, jextractJavaReference, "getDescription");
    // getReachability
    if ((REACHABILITY & members) != 0)
        testJavaEquals(ddrJavaReference, jextractJavaReference, "getReachability");
    // getReferenceType
    if ((REFERENCE_TYPE & members) != 0)
        testJavaEquals(ddrJavaReference, jextractJavaReference, "getReferenceType");
    // getRootType
    if ((ROOT_TYPE & members) != 0)
        testJavaEquals(ddrJavaReference, jextractJavaReference, "getRootType");
    // getSource
    if ((SOURCE & members) != 0) {
        try {
            javaClassComparator.testComparatorEquals(ddrObject, jextractObject, "getSource");
            return;
        } catch (ClassCastException e) {
        // Do nothing.
        }
        // We only get here if the target was NOT a JavaClass
        try {
            javaObjectComparator.testComparatorEquals(ddrObject, jextractObject, "getSource");
            return;
        } catch (ClassCastException e) {
        // Do nothing
        }
        // We only get here if the target was NOT a JavaClass or a JavaObject
        javaStackFrameComparator.testComparatorEquals(ddrObject, jextractObject, "getSource", JavaStackFrameComparator.BASE_POINTER + JavaStackFrameComparator.LOCATION);
    }
    // getTarget
    if ((TARGET & members) != 0) {
        try {
            javaClassComparator.testComparatorEquals(ddrObject, jextractObject, "getTarget");
            return;
        } catch (ClassCastException e) {
        // Do nothing.
        }
        // We only get here if the target was NOT a JavaClass
        javaObjectComparator.testComparatorEquals(ddrObject, jextractObject, "getTarget");
    }
    // isClassReference
    if ((IS_CLASS_REFERENCE & members) != 0)
        testJavaEquals(ddrJavaReference, jextractJavaReference, "isClassReference");
    // isObjectReference
    if ((IS_OBJECT_REFERENCE & members) != 0)
        testJavaEquals(ddrJavaReference, jextractJavaReference, "isObjectReference");
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference)

Example 7 with JavaReference

use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.

the class PHDJavaRuntime method findLoaders.

/**
 * Helper method to try to allocate classes to the correct class loader
 * There isn't an explicit mention of the loader, but an outbound reference might be to the loader.
 * First find all the objects which are class loaders.
 * The look at each file, see if it has a reference to a loader object and if so allocate it to
 * that loader.
 * @param file
 * @throws IOException
 */
private void findLoaders(HeapdumpReader newreader) throws IOException {
    // Where all the classes orginally have been put
    final PHDJavaClassLoader boot = loaders.get(null);
    // Might fail to find a class with a very corrupt dump
    final JavaClass jlc = findClass("java/lang/Class");
    final long jlcAddress = jlc == null || jlc.getID() == null ? 0 : jlc.getID().getAddress();
    // Find all the class loader classes
    final JavaClass jcl = findClass("java/lang/ClassLoader");
    final HashMap<Long, JavaClass> classLoaderClasses = new HashMap<Long, JavaClass>();
    for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
        JavaClass cls = it.next();
        if (cls instanceof CorruptData)
            continue;
        try {
            // Avoid bug with superclass loops by remembering superclasses
            // PHD Version 4 bug - bad superclass: J2RE 5.0 IBM J9 2.3 AIX ppc64-64 build 20080314_17962_BHdSMr
            HashSet<JavaClass> supers = new HashSet<JavaClass>();
            for (JavaClass j1 = cls; j1 != null && supers.add(j1); j1 = j1.getSuperclass()) {
                /* 
					 * See if either a superclass is java.lang.ClassLoader
					 * or if no superclass information is available (old Java 5)
					 * whether the name ends with "ClassLoader"
					 */
                if (j1.equals(jcl) || cls.getSuperclass() == null && !j1.isArray() && j1.getName().endsWith("ClassLoader")) {
                    ImagePointer ip = cls.getID();
                    if (ip != null) {
                        classLoaderClasses.put(ip.getAddress(), cls);
                    }
                }
            }
        } catch (CorruptDataException e) {
        // Ignore
        }
    }
    // Number of class objects not found at class addresses
    final int[] onHeapClasses = new int[1];
    // Find all the objects which are class loaders
    final PHDJavaHeap heap = heaps.get(0);
    final HashMap<Long, JavaObject> classObjects = new HashMap<Long, JavaObject>();
    // HeapdumpReader newreader = new HeapdumpReader(file, parentImage);
    final int adjustLen = newreader.version() == 4 && newreader.isJ9() ? 1 : 0;
    try {
        newreader.parse(new PortableHeapDumpListener() {

            public void classDump(long address, long superAddress, String name, int size, int flags, int hashCode, LongEnumeration refs) throws Exception {
            }

            public void objectArrayDump(long address, long classAddress, int flags, int hashCode, LongEnumeration refs, int length, long instanceSize) throws Exception {
                if (extraObjectsCache.containsKey(address)) {
                    // Don't bother saving reference information - we can get it later
                    JavaObject jo = new PHDJavaObject.Builder(heap, address, arrayOf(classAddress, refs, adjustLen), flags, hashCode).length(length - adjustLen).instanceSize(instanceSize).build();
                    extraObjectsCache.put(address, jo);
                }
            }

            public void objectDump(long address, long classAddress, int flags, int hashCode, LongEnumeration refs, long instanceSize) throws Exception {
                JavaClass cls = classLoaderClasses.get(classAddress);
                JavaObject jo;
                if (cls != null) {
                    // Object of type java.lang.ClassLoader, so create the object and the class loader
                    jo = new PHDJavaObject.Builder(heap, address, cls, flags, hashCode).refs(refs, 0).length(PHDJavaObject.SIMPLE_OBJECT).instanceSize(instanceSize).build();
                    PHDJavaClassLoader load = new PHDJavaClassLoader(jo);
                    loaders.put(jo, load);
                } else if (classAddress == jlcAddress) {
                    if (boot.findClass(address) == null) {
                        ++onHeapClasses[0];
                    }
                    jo = new PHDJavaObject.Builder(heap, address, jlc, flags, hashCode).refs(refs, 0).length(PHDJavaObject.SIMPLE_OBJECT).instanceSize(instanceSize).build();
                    classObjects.put(address, jo);
                } else {
                    jo = null;
                }
                if (extraObjectsCache.containsKey(address)) {
                    if (jo == null) {
                        jo = new PHDJavaObject.Builder(heap, address, findClass(classAddress), flags, hashCode).refs(refs, 0).length(PHDJavaObject.SIMPLE_OBJECT).build();
                    }
                    extraObjectsCache.put(address, jo);
                }
            }

            public void primitiveArrayDump(long address, int type, int length, int flags, int hashCode, long instanceSize) throws Exception {
                if (extraObjectsCache.containsKey(address)) {
                    // Create a full object as we have the data
                    JavaObject jo = new PHDJavaObject.Builder(heap, address, findArrayOfType(type), flags, hashCode).refsAsArray(NOREFS, 0).length(length).instanceSize(instanceSize).build();
                    extraObjectsCache.put(address, jo);
                }
            }
        });
    } catch (Exception e) {
    // Ignore the exception - we will have seen it elsewhere
    // e.printStackTrace();
    } finally {
        newreader.close();
        newreader = null;
    }
    // Assign classes to the correct loaders
    // Also try to set up on/off-heap class addresses
    PHDJavaClassLoader boot2 = null;
    int foundLoader = 0;
    int notFoundLoader = 0;
    // How many java/lang classes the possible boot loader has loaded
    int loaderJavaLangCount = 0;
    boolean useFirstObjectRefAsLoader = onHeapClasses[0] == 0;
    for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
        JavaClass j1 = it.next();
        PHDJavaClassLoader bestLoader = null;
        for (Iterator<JavaReference> it2 = j1.getReferences(); it2.hasNext(); ) {
            JavaReference jr = it2.next();
            try {
                // Is the first outbound object reference to a class loader?
                if (jr.isObjectReference()) {
                    JavaObject jo = (JavaObject) jr.getTarget();
                    PHDJavaClassLoader newLoader = loaders.get(jo);
                    if (newLoader != null) {
                        if (bestLoader == null || !useFirstObjectRefAsLoader) {
                            bestLoader = newLoader;
                        }
                    } else if (onHeapClasses[0] > 0) {
                        long addr = jo.getID().getAddress();
                        JavaObject jo2 = classObjects.get(addr);
                        if (jo2 != null) {
                            // For Java 6 jdmpview PHD files the on-heap class object is the last ref
                            // retrieve the full JavaObject from walking the heap earlier
                            ((PHDJavaClass) j1).setJavaObject(jo2);
                        }
                    }
                    // unless using off-heap classes when it is the last reference.
                    if (!j1.isArray() && useFirstObjectRefAsLoader && onHeapClasses[0] == 0)
                        break;
                }
            } catch (CorruptDataException e) {
            // e.printStackTrace();
            } catch (DataUnavailable e) {
            // e.printStackTrace();
            }
        }
        if (bestLoader != null) {
            ++foundLoader;
            // Don't remove the classes from the original loader, nor change the loader
            // as otherwise finding the array type fails
            bestLoader.prepareToMove(boot, j1);
            // Is the class by any chance the type of the class loader?
            try {
                if (boot2 == null && (j1.equals(jlc) || j1.equals(bestLoader.getObject().getJavaClass()))) {
                    // We have found the new bootstrap class loader
                    // Beware java 1.4.2 com/ibm/rmi/util/ClassInfo$NULL_CL_CLASS passes this test!
                    boot2 = bestLoader;
                }
                if (boot2 == bestLoader && j1.getName().startsWith("java/lang/"))
                    ++loaderJavaLangCount;
            } catch (CorruptDataException e) {
            }
        } else {
            ++notFoundLoader;
        }
        // Try retrieving the full JavaObject for the JavaClass
        try {
            JavaObject jo = j1.getObject();
            if (jo != null) {
                long addr = jo.getID().getAddress();
                JavaObject jo2 = classObjects.get(addr);
                if (jo2 != null) {
                    ((PHDJavaClass) j1).setJavaObject(jo2);
                }
            }
        } catch (CorruptDataException e) {
        }
    }
    // Ignore a bootstrap loader which hasn't loaded 5 java/lang classes
    if (loaderJavaLangCount < 5)
        boot2 = null;
    // Haven't found any loaders, but have a javacore file with loader information
    if (metaJavaRuntime != null) {
        for (Iterator i = metaJavaRuntime.getJavaClassLoaders(); i.hasNext(); ) {
            Object next = i.next();
            if (next instanceof CorruptData)
                continue;
            JavaClassLoader jcl2 = (JavaClassLoader) next;
            try {
                JavaObject lo = jcl2.getObject();
                if (lo != null) {
                    ImagePointer addr = lo.getID();
                    if (addr != null) {
                        ImagePointer ip = space.getPointer(addr.getAddress());
                        JavaObject jo = getObjectAtAddress(ip);
                        PHDJavaClassLoader newLoader = loaders.get(jo);
                        JavaClass loaderClass;
                        if (newLoader == null) {
                            try {
                                // Should be safe to find the class of 'jo' without rereading the PHD file
                                // as at least a dummy object should be in the extra objects cache.
                                // It could be that the object is still a dummy one with no proper class.
                                loaderClass = jo.getJavaClass();
                            } catch (CorruptDataException e) {
                                loaderClass = null;
                            }
                            JavaClass javacoreLoaderClass;
                            try {
                                javacoreLoaderClass = lo.getJavaClass();
                            } catch (CorruptDataException e) {
                                javacoreLoaderClass = null;
                            }
                            // Mismatch occurs with J2RE 5.0 IBM J9 2.3 Linux amd64-64 build j9vmxa6423-20091104
                            if (loaderClass != null && javacoreLoaderClass != null && (loaderClass.isArray() || loaderClass.getID() != null && javacoreLoaderClass.getID() != null && loaderClass.getID().getAddress() != javacoreLoaderClass.getID().getAddress())) {
                            // System.out.println("Skipping loader "+newLoader+" "+jo+" "+jo.getJavaClass()+" "+lo+" "+lo.getJavaClass()+" "+Long.toHexString(addr.getAddress())+" "+ip);
                            } else {
                                // The object should have been listed in the extra objects, so may now be the proper object
                                newLoader = new PHDJavaClassLoader(jo);
                                loaders.put(jo, newLoader);
                            }
                        } else {
                            // Replace with the offical object
                            jo = newLoader.getObject();
                            loaderClass = jo.getJavaClass();
                        }
                        if (newLoader != null) {
                            for (Iterator i2 = jcl2.getDefinedClasses(); i2.hasNext(); ) {
                                Object next2 = i2.next();
                                if (next2 instanceof CorruptData)
                                    continue;
                                JavaClass jc2 = (JavaClass) next2;
                                ImagePointer ip2 = jc2.getID();
                                JavaClass j1;
                                if (ip2 != null) {
                                    long claddr = ip2.getAddress();
                                    j1 = boot.findClass(claddr);
                                    // Not found by address, so try by name.
                                    if (j1 == null) {
                                        // But only if it is the only class of that name
                                        j1 = boot.findClassUnique(jc2.getName());
                                    } else {
                                        // Found by address
                                        try {
                                            j1.getName();
                                        } catch (CorruptDataException e) {
                                            // Our class doesn't have a name, so perhaps the javacore has the name
                                            try {
                                                String actualName = jc2.getName();
                                                PHDJavaClass pj1 = (PHDJavaClass) j1;
                                                // We will need to reindex the classloader as the name as changed
                                                pj1.setName(actualName);
                                            } catch (CorruptDataException e2) {
                                            }
                                        }
                                    }
                                } else {
                                    // But only if it is the only class of that name
                                    j1 = boot.findClassUnique(jc2.getName());
                                }
                                if (j1 != null) {
                                    newLoader.prepareToMove(boot, j1);
                                    // listed in javacore causes problems as byte etc. aren't listed
                                    if (j1.equals(loaderClass) || j1.equals(jlc)) {
                                        // We have found the new bootstrap class loader
                                        boot2 = newLoader;
                                    }
                                    for (Iterator i3 = jc2.getDeclaredMethods(); i3.hasNext(); ) {
                                        Object next3 = i3.next();
                                        if (next3 instanceof CorruptData)
                                            continue;
                                        JavaMethod jm = (JavaMethod) next3;
                                        PHDJavaClass pj1 = (PHDJavaClass) j1;
                                        pj1.addMethod(new PHDJavaMethod(space, pj1, jm));
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (CorruptDataException e) {
            } catch (DataUnavailable e) {
            } catch (MemoryAccessException e) {
            }
        }
    }
    // Move the classes to the correct class loaders
    for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
        JavaClass j1 = it.next();
        try {
            JavaClassLoader jcl2 = j1.getClassLoader();
            if (!boot.equals(jcl2) && jcl2 instanceof PHDJavaClassLoader) {
                transferClass(boot, (PHDJavaClassLoader) jcl2, j1);
            }
        } catch (CorruptDataException e) {
        }
    }
    // Reindex the loaders to account for the removed classes
    for (PHDJavaClassLoader loader : loaders.values()) {
        loader.initCache();
    }
    if (boot2 != null) {
        // Move remaining classes to new boot loader
        for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
            JavaClass j1 = it.next();
            boot2.prepareToMove(boot, j1);
            transferClass(boot, boot2, j1);
        }
        // index the new boot loader to account for the added files
        boot2.initCache();
        // Remove the original boot class loader as it has no classes
        loaders.remove(null);
    } else {
        // There may be duplicate array classes in the boot loader
        for (Iterator<JavaClass> it = boot.getDefinedClasses(); it.hasNext(); ) {
            JavaClass j1 = it.next();
            JavaClass j2 = boot.setArrayType(this, boot, j1);
        }
        // index the boot loader to account for the added files
        boot.initCache();
    }
}
Also used : PortableHeapDumpListener(com.ibm.dtfj.phd.parser.PortableHeapDumpListener) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImagePointer(com.ibm.dtfj.image.ImagePointer) JavaReference(com.ibm.dtfj.java.JavaReference) LongEnumeration(com.ibm.dtfj.phd.util.LongEnumeration) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaMethod(com.ibm.dtfj.java.JavaMethod) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException) HashSet(java.util.HashSet) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException) IOException(java.io.IOException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JavaClass(com.ibm.dtfj.java.JavaClass) JavaObject(com.ibm.dtfj.java.JavaObject) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) CorruptData(com.ibm.dtfj.image.CorruptData) JavaObject(com.ibm.dtfj.java.JavaObject)

Example 8 with JavaReference

use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.

the class DTFJJavaClass method addStaticFieldReferences.

@SuppressWarnings("rawtypes")
private void addStaticFieldReferences(List<Object> references) {
    JavaReference jRef;
    Iterator declaredFieldIt = getDeclaredFields();
    // can get corrupt data returned through the field iterator as it's coming from DTFJ
    Object obj = null;
    while ((declaredFieldIt.hasNext() && (obj = declaredFieldIt.next()) instanceof DTFJJavaField)) {
        DTFJJavaField jField = (DTFJJavaField) obj;
        if (jField instanceof DTFJJavaFieldStatic) {
            JavaObject jObject;
            try {
                char type = jField.getSignature().charAt(0);
                if (type == DTFJConstants.OBJECT_PREFIX_SIGNATURE || type == DTFJConstants.ARRAY_PREFIX_SIGNATURE) {
                    jObject = (JavaObject) jField.get(null);
                    if (jObject != null) {
                        // build a JavaReference type and add the reference to the container.
                        String fieldName = jField.getName();
                        String description = "Static field";
                        if (null != fieldName) {
                            description = description + " [field name:" + fieldName + "]";
                        }
                        jRef = new DTFJJavaReference(this, jObject, description, JavaReference.REFERENCE_STATIC_FIELD, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                        references.add(jRef);
                    }
                }
            } catch (Throwable t) {
                CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                references.add(cd);
            }
        }
    }
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) JavaObject(com.ibm.dtfj.java.JavaObject) 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 JavaReference

use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.

the class DTFJJavaClass method addClassObjectReference.

private void addClassObjectReference(List<Object> coll) {
    JavaReference jRef = null;
    try {
        com.ibm.dtfj.java.JavaObject classObject = this.getObject();
        if (null != classObject) {
            jRef = new DTFJJavaReference(this, classObject, "Class object", JavaReference.REFERENCE_CLASS_OBJECT, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
            coll.add(jRef);
        }
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        coll.add(cd);
    }
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Example 10 with JavaReference

use of com.ibm.dtfj.java.JavaReference in project openj9 by eclipse.

the class DTFJJavaObject method getReferences.

@SuppressWarnings("rawtypes")
public Iterator getReferences() {
    boolean isClass = false;
    boolean isClassLoader = false;
    boolean isWeakReference = false;
    boolean isSoftReference = false;
    boolean isPhantomReference = false;
    if (null == references) {
        references = new LinkedList<Object>();
        try {
            // find this object's class
            JavaClass jClass = getJavaClass();
            // add a reference to the object's class
            if (null != jClass) {
                JavaReference ref = new DTFJJavaReference(this, jClass, "Class", JavaReference.REFERENCE_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                references.add(ref);
            }
            if (isArray()) {
                if (isObjectArray()) {
                    addObjectArrayReferences();
                }
            } else {
                isClass = (jClass != null) && jClass.getName().equals("java/lang/Class");
                List<JavaClass> superClasses = new LinkedList<JavaClass>();
                // Do superclass walk
                while (jClass != null) {
                    String className = jClass.getName();
                    isClassLoader |= className.equals("java/lang/ClassLoader");
                    isWeakReference |= className.equals("java/lang/ref/WeakReference");
                    isSoftReference |= className.equals("java/lang/ref/SoftReference");
                    isPhantomReference |= className.equals("java/lang/ref/PhantomReference");
                    superClasses.add(jClass);
                    jClass = jClass.getSuperclass();
                }
                int reachability = isWeakReference ? JavaReference.REACHABILITY_WEAK : isSoftReference ? JavaReference.REACHABILITY_SOFT : isPhantomReference ? JavaReference.REACHABILITY_PHANTOM : JavaReference.REACHABILITY_STRONG;
                for (JavaClass clazz : superClasses) {
                    addFieldReferences(clazz, reachability);
                }
            }
        } catch (CorruptDataException e) {
            // Corrupt data, so add it to the container.
            references.add(e.getCorruptData());
        } catch (Throwable t) {
            CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
            references.add(cd);
        }
        // Now add association-specific references
        if (isClassLoader) {
            try {
                JavaClassLoader associatedClassLoader = getAssociatedClassLoader();
                if (associatedClassLoader != null) {
                    for (Iterator classes = associatedClassLoader.getDefinedClasses(); classes.hasNext(); ) {
                        Object potentialClass = classes.next();
                        if (potentialClass instanceof JavaClass) {
                            JavaClass currentClass = (JavaClass) potentialClass;
                            JavaReference ref = new DTFJJavaReference(this, currentClass, "Loaded class", JavaReference.REFERENCE_LOADED_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                            references.add(ref);
                        }
                    }
                } else {
                    references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Couldn't find associated JavaClassLoader for classloader object " + this));
                }
            } catch (Throwable t) {
                CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                references.add(cd);
            }
        }
        if (isClass) {
            try {
                JavaClass associatedClass = getAssociatedClass();
                if (associatedClass != null) {
                    JavaReference ref = new DTFJJavaReference(this, associatedClass, "Associated class", JavaReference.REFERENCE_ASSOCIATED_CLASS, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
                    references.add(ref);
                } else {
                    // No associated class found. For anonymous classes this is expected, the class is not defined in a classloader.
                    J9ClassPointer j9Class = ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object);
                    if (!J9ClassHelper.isAnonymousClass(j9Class)) {
                        // Not an anonymous class, so something is wrong/damaged, add a corrupt data object to the references list
                        references.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Couldn't find associated JavaClass for Class object " + this));
                    }
                }
            } catch (Throwable t) {
                CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
                references.add(cd);
            }
        }
    }
    return references.iterator();
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) LinkedList(java.util.LinkedList) JavaReference(com.ibm.dtfj.java.JavaReference) JavaClass(com.ibm.dtfj.java.JavaClass) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) 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) CorruptJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Aggregations

JavaReference (com.ibm.dtfj.java.JavaReference)13 JavaObject (com.ibm.dtfj.java.JavaObject)11 CorruptData (com.ibm.dtfj.image.CorruptData)10 Iterator (java.util.Iterator)8 JavaClass (com.ibm.dtfj.java.JavaClass)7 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)6 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)6 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)6 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)3 J9DDRDTFJUtils.corruptIterator (com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator)3 J9Object (com.ibm.j9ddr.vm29.structure.J9Object)3 J9ObjectFieldOffsetIterator (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffsetIterator)2 DTFJConstantPoolIterator (com.ibm.j9ddr.vm29.view.dtfj.java.j9.DTFJConstantPoolIterator)2 HashMap (java.util.HashMap)2 ImagePointer (com.ibm.dtfj.image.ImagePointer)1 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)1 JavaLocation (com.ibm.dtfj.java.JavaLocation)1 JavaMethod (com.ibm.dtfj.java.JavaMethod)1 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)1 JavaStackFrame (com.ibm.dtfj.java.JavaStackFrame)1