Search in sources :

Example 31 with ImagePointer

use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.

the class JavaRuntime method checkDeferredMonitors.

private void checkDeferredMonitors() {
    int errs = 0;
    for (int i = 0; i < deferMonitors.size(); i++) {
        DeferMonitor mon = (DeferMonitor) deferMonitors.get(i);
        if (mon.id != 0) {
            // At this point we attempt a cover-up operation by building the monitor
            ImagePointer ptr = pointerInAddressSpace(mon.id);
            JavaMonitor autoMon = new JavaMonitor(this, ptr, "Auto-generated monitor #" + mon.id, null, 0);
            // adding this to the runtime automatically resolves any other referencing deferred monitors
            addMonitor(autoMon);
            errs++;
        }
    }
    deferMonitors.clear();
// if (errs > 0) {
// System.out.println("Some deferred monitors not processed " + errs);
// }
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer)

Example 32 with ImagePointer

use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.

the class JCJavaClassLoader method findClass.

/**
 */
public JavaClass findClass(String className) {
    JavaClass foundClass = null;
    if (fClassNames.containsKey(className)) {
        ImagePointer ip = (ImagePointer) fClassNames.get(className);
        if (ip != null) {
            // By class ID
            long id = ip.getAddress();
            foundClass = fRuntime.findJavaClass(id);
        } else {
            // By class name
            foundClass = fRuntime.findJavaClass(className);
        }
    }
    return foundClass;
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JavaClass(com.ibm.dtfj.java.JavaClass)

Example 33 with ImagePointer

use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.

the class JCJavaRuntime method addJavaClass.

/**
 * NON-DTFJ
 * <br>
 * <b>For internal building purposes only</b>. Do not call outside the DTFJ implementation.
 * <br><br>
 * Two separate maps are kept for classes. One based on class ID, the other based on class name. Both
 * are used for lookups while building the runtime object. When a valid javaclass is added, it gets
 * added at least the name-based map, and may be added to the ID-based map if the ID is available. The
 * class name of the java class is a requirement, so this field must be set in the java class being passed.
 *
 * @param javaClass must not be null or exception thrown
 * @throws JCRegistrationFailureException if java class is null
 */
public void addJavaClass(JCJavaClass javaClass) throws JCInvalidArgumentsException {
    if (javaClass == null) {
        throw new JCInvalidArgumentsException("Must pass a valid javaClass");
    }
    String javaClassName = javaClass.internalGetName();
    ImagePointer pointer = javaClass.getID();
    if (pointer != null) {
        long id = pointer.getAddress();
        fJavaClassIDs.put(new LookupKey(id), javaClass);
    }
    fJavaClasses.put(javaClassName, javaClass);
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) LookupKey(com.ibm.dtfj.image.javacore.LookupKey)

Example 34 with ImagePointer

use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.

the class JCJavaRuntime method findJavaThread.

/**
 * NON-DTFJ
 * <br>
 * <b>For internal building purposes only</b>. Do not call outside the DTFJ implementation.
 * <br><br>
 * In most cases, the threadID is the tid in a javacore, but in some other occasions, the id
 * passed could be the system_thread_id or even the native thread. If a java thread is not
 * found via tid, see if it can be found indirectly by an image thread that may be associated
 * with the java thread (the image thread has a system thread ID as well as a native thread ID).
 * @param threadID usually, tid in a javacore, may be id of some other internal vm datastructure.
 * @return found java thread or null.
 */
public JCJavaThread findJavaThread(long threadID) {
    Object javaThread = null;
    fIDLookupKey.setKey(threadID);
    if ((javaThread = fJavaThreads.get(fIDLookupKey)) == null) {
        Iterator it = fJavaThreads.values().iterator();
        while (javaThread == null && it.hasNext()) {
            JCJavaThread jThread = (JCJavaThread) it.next();
            JCImageThread imageThread = jThread.internalGetImageThread();
            if (imageThread != null) {
                // lookup via systemthreadID
                ImagePointer pointer = imageThread.getSystemThreadID();
                long address = (pointer != null) ? pointer.getAddress() : IBuilderData.NOT_AVAILABLE;
                if (address != IBuilderData.NOT_AVAILABLE && address == threadID) {
                    javaThread = jThread;
                } else // lookup via nativethreadID. This is always set for any valid image thread.
                {
                    pointer = imageThread.getInternalID();
                    if (pointer.getAddress() == threadID) {
                        javaThread = jThread;
                    }
                }
            }
        }
    }
    return (JCJavaThread) javaThread;
}
Also used : JCImageThread(com.ibm.dtfj.image.javacore.JCImageThread) ImagePointer(com.ibm.dtfj.image.ImagePointer) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject)

Example 35 with ImagePointer

use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.

the class ImageAddressSpaceBuilder method addImageSection.

public ImageSection addImageSection(String name, long base, long size) {
    ImagePointer basePointer = fImageAddressSpace.getPointer(base);
    ImageSection section = new JCImageSection(name, basePointer, size);
    fImageAddressSpace.addImageSection(section);
    return section;
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) ImageSection(com.ibm.dtfj.image.ImageSection) JCImageSection(com.ibm.dtfj.image.javacore.JCImageSection) JCImageSection(com.ibm.dtfj.image.javacore.JCImageSection)

Aggregations

ImagePointer (com.ibm.dtfj.image.ImagePointer)45 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)19 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)12 JavaClass (com.ibm.dtfj.java.JavaClass)9 JCInvalidArgumentsException (com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)8 CorruptData (com.ibm.dtfj.image.j9.CorruptData)7 JavaObject (com.ibm.dtfj.java.JavaObject)7 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)7 Iterator (java.util.Iterator)7 JCJavaClass (com.ibm.dtfj.java.javacore.JCJavaClass)6 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)5 JCJavaObject (com.ibm.dtfj.java.javacore.JCJavaObject)4 ArrayList (java.util.ArrayList)4 Vector (java.util.Vector)4 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)3 ImageSection (com.ibm.dtfj.image.ImageSection)3 JCImageThread (com.ibm.dtfj.image.javacore.JCImageThread)3 JCJavaMonitor (com.ibm.dtfj.java.javacore.JCJavaMonitor)3 IOException (java.io.IOException)3 CorruptData (com.ibm.dtfj.image.CorruptData)2