Search in sources :

Example 1 with JavaObject

use of com.ibm.dtfj.java.j9.JavaObject 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)

Aggregations

CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 JavaClass (com.ibm.dtfj.java.JavaClass)1 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)1 JavaMonitor (com.ibm.dtfj.java.JavaMonitor)1 JavaThread (com.ibm.dtfj.java.JavaThread)1 JavaObject (com.ibm.dtfj.java.j9.JavaObject)1 Iterator (java.util.Iterator)1