Search in sources :

Example 1 with JavaClassLoader

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

the class JExtractXMLGenerator method generateClassloaders.

@SuppressWarnings("unchecked")
private void generateClassloaders(JavaRuntime rt) throws Exception {
    for (Iterator loaders = rt.getJavaClassLoaders(); loaders.hasNext(); ) {
        JavaClassLoader loader = (JavaClassLoader) loaders.next();
        xml.append("<classloader id=\"");
        // xml.append(loader.getID());
        xml.append("\" obj=\"0x");
        xml.append(Long.toHexString(loader.getObject().getID().getAddress()));
        xml.append("\">\n");
        for (Iterator classes = loader.getCachedClasses(); classes.hasNext(); ) {
            JavaClass clazz = (JavaClass) classes.next();
            xml.append("<class id=\"0x");
            xml.append(Long.toHexString(clazz.getID().getAddress()));
            xml.append("\" />\n");
        }
        xml.append("</classloader>\n");
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator)

Example 2 with JavaClassLoader

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

the class ClassLoaderSectionParser method processClassLoaders.

/**
 * Grammar subsection 2CLTEXTCLLOAD
 * Although classes must be associated with classloaders in DTFJ, if a class loader
 * is not built due to corruption of data, yet a class list still exists for it,
 * the parser still has to process the class data from the buffer any way,
 * even though it may not be added to
 * DTFJ by the builder.
 */
private void processClassLoaders(IAttributeValueMap results) throws ParserException {
    JavaClassLoader loader = null;
    String cl_name = results.getTokenValue(CL_ATT__NAME);
    long cl_address = results.getLongValue(CL_ATT_ADDRESS);
    try {
        loader = fRuntimeBuilder.addClassLoader(cl_name, cl_address, cl_address);
    } catch (BuilderFailureException e) {
        handleError("Failed to add class loader: " + cl_name + " " + cl_address + " ", e);
    }
    while ((results = processTagLineOptional(T_3CLTEXTCLASS)) != null) {
        String className = results.getTokenValue(CLASS_ATT_NAME);
        long classID = results.getLongValue(CLASS_ATT_ADDRESS);
        try {
            fRuntimeBuilder.addClass(loader, className, classID, IBuilderData.NOT_AVAILABLE, null);
        } catch (BuilderFailureException e) {
            handleError("Failed to add class: " + className + " " + classID + " ", e);
        }
    }
}
Also used : JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException)

Example 3 with JavaClassLoader

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

the class NodeJavaVM method didFinishParsing.

public void didFinishParsing() {
    Iterator classLoaders = _runtime.getJavaClassLoaders();
    while (classLoaders.hasNext()) {
        Object potentialClassLoader = classLoaders.next();
        if (potentialClassLoader instanceof JavaClassLoader) {
            JavaClassLoader loader = (JavaClassLoader) potentialClassLoader;
            // sets the associated object
            try {
                Object potentialLoaderObject = loader.getObject();
                if (null != potentialLoaderObject && potentialLoaderObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
                    JavaObject loaderObject = (com.ibm.dtfj.java.j9.JavaObject) potentialLoaderObject;
                    loaderObject.setAssociatedClassLoader(loader);
                    _runtime.addSpecialObject(loaderObject);
                    Iterator classes = loader.getDefinedClasses();
                    while (classes.hasNext()) {
                        Object potentialClass = classes.next();
                        if (potentialClass instanceof JavaClass) {
                            JavaClass theClass = (JavaClass) potentialClass;
                            try {
                                Object potentialClassObject = theClass.getObject();
                                if (null != potentialClassObject && potentialClassObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
                                    JavaObject classObject = (com.ibm.dtfj.java.j9.JavaObject) potentialClassObject;
                                    classObject.setAssociatedClass(theClass);
                                    _runtime.addSpecialObject(classObject);
                                }
                            } catch (CorruptDataException e) {
                            // no reason to skip the other classloaders/classes just because an exception is thrown on one class
                            } catch (IllegalArgumentException e) {
                            // CMVC 173262 : JavaClass.getObject() uses JavaHeap.getObjectAtAddress() which can throw this exception
                            }
                        }
                    }
                }
            } catch (CorruptDataException e) {
            // associated object not set
            }
        }
    }
    Iterator monitors = _runtime.getMonitors();
    while (monitors.hasNext()) {
        Object potentialMonitor = monitors.next();
        if (potentialMonitor instanceof JavaMonitor) {
            JavaMonitor monitor = (JavaMonitor) potentialMonitor;
            // sets the associated object
            Object potentialMonitorObject = monitor.getObject();
            if (null != potentialMonitorObject && potentialMonitorObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
                JavaObject monitorObject = (com.ibm.dtfj.java.j9.JavaObject) potentialMonitorObject;
                monitorObject.setAssociatedMonitor(monitor);
                _runtime.addSpecialObject(monitorObject);
            }
        }
    }
    Iterator threads = _runtime.getThreads();
    while (threads.hasNext()) {
        Object potentialThread = threads.next();
        if (potentialThread instanceof JavaThread) {
            JavaThread thread = (JavaThread) potentialThread;
            // sets the associated object
            try {
                Object potentialThreadObject = thread.getObject();
                if (null != potentialThreadObject && potentialThreadObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
                    JavaObject threadObject = (com.ibm.dtfj.java.j9.JavaObject) potentialThreadObject;
                    threadObject.setAssociatedThread(thread);
                    _runtime.addSpecialObject(threadObject);
                }
            } catch (CorruptDataException e) {
            // associated object not set
            }
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.j9.JavaObject) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JavaMonitor(com.ibm.dtfj.java.JavaMonitor) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaObject(com.ibm.dtfj.java.j9.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) JavaObject(com.ibm.dtfj.java.j9.JavaObject)

Example 4 with JavaClassLoader

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

the class DTFJJavaClass method addClassLoaderReference.

private void addClassLoaderReference(List<Object> coll) {
    JavaReference jRef = null;
    try {
        JavaClassLoader classLoader = this.getClassLoader();
        if (null != classLoader) {
            JavaObject classLoaderObject = classLoader.getObject();
            if (null != classLoaderObject) {
                jRef = new DTFJJavaReference(this, classLoaderObject, "Classloader", JavaReference.REFERENCE_CLASS_LOADER, 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) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Example 5 with JavaClassLoader

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

the class DTFJJavaFieldInstance method _findClassForName.

/**
 * private method to search all classloaders for a given class
 */
private JavaClass _findClassForName(String candidateClass) throws CorruptDataException {
    DTFJJavaRuntime rt = DTFJContext.getRuntime();
    Iterator allLoaders = rt.getJavaClassLoaders();
    JavaClass subclass = null;
    while (allLoaders.hasNext() && (null == subclass)) {
        JavaClassLoader loader = (JavaClassLoader) allLoaders.next();
        Iterator classes = loader.getDefinedClasses();
        while (classes.hasNext() && (null == subclass)) {
            JavaClass oneClass = (JavaClass) classes.next();
            if (oneClass.getName().equals(candidateClass)) {
                subclass = oneClass;
                break;
            }
        }
    }
    return subclass;
}
Also used : JavaClass(com.ibm.dtfj.java.JavaClass) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) Iterator(java.util.Iterator)

Aggregations

JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)32 JavaClass (com.ibm.dtfj.java.JavaClass)24 Iterator (java.util.Iterator)16 JavaObject (com.ibm.dtfj.java.JavaObject)15 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)14 ArrayList (java.util.ArrayList)7 CorruptData (com.ibm.dtfj.image.CorruptData)6 JavaReference (com.ibm.dtfj.java.JavaReference)3 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)3 List (java.util.List)3 DTFJException (com.ibm.dtfj.image.DTFJException)2 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 ImagePointer (com.ibm.dtfj.image.ImagePointer)2 JavaMethod (com.ibm.dtfj.java.JavaMethod)2 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)2 PortableHeapDumpListener (com.ibm.dtfj.phd.parser.PortableHeapDumpListener)2 LongEnumeration (com.ibm.dtfj.phd.util.LongEnumeration)2 J9DDRDTFJUtils.corruptIterator (com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator)2 J9Object (com.ibm.j9ddr.vm29.structure.J9Object)2 CorruptJavaObject (com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject)2