Search in sources :

Example 86 with CorruptDataException

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

the class JavaStaticField method parse.

private long parse(int maxLength) throws CorruptDataException {
    if (null == _value)
        throw new CorruptDataException(new CorruptData("parse error: value is null", null));
    if (_value.length() > maxLength)
        throw new CorruptDataException(new CorruptData("parse error: value [" + _value + "] length " + _value.length() + " exceeds maximum of " + maxLength, null));
    if (16 == _value.length()) {
        // split and shift since this would overflow
        String highS = _value.substring(0, 8);
        String lowS = _value.substring(8, 16);
        long high = Long.parseLong(highS, 16);
        long low = Long.parseLong(lowS, 16);
        return (high << 32) | low;
    }
    return Long.parseLong(_value, 16);
}
Also used : CorruptData(com.ibm.dtfj.image.j9.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 87 with CorruptDataException

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

the class JavaThread method getName.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.java.JavaThread#getName()
	 */
public String getName() throws CorruptDataException {
    JavaObject theObject = getObject();
    if (null != theObject) {
        JavaClass threadClass = _javaLangThreadSuperclass();
        Iterator fields = threadClass.getDeclaredFields();
        while (fields.hasNext()) {
            JavaField oneField = (JavaField) fields.next();
            if (oneField.getName().equals("name")) {
                try {
                    return oneField.getString(theObject);
                } catch (MemoryAccessException e) {
                    throw new CorruptDataException(new CorruptData("unable to read memory for 'name' field", null));
                }
            }
        }
        throw new CorruptDataException(new CorruptData("unable to find 'name' field", null));
    } else {
        return "vmthread @" + _jniEnv.getAddress();
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) CorruptData(com.ibm.dtfj.image.j9.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 88 with CorruptDataException

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

the class JavaHeapRegion method getObjectAtAddress.

public JavaObject getObjectAtAddress(ImagePointer address) throws CorruptDataException, IllegalArgumentException {
    JavaObject object = null;
    if ((null != address) && (0 != address.getAddress())) {
        // try the special objects cache first...
        JavaObject specialObject = _javaVM.getSpecialObject(address);
        if (null != specialObject) {
            return specialObject;
        }
        // CMVC 173262 - check alignment
        if ((address.getAddress() & (_objectAlignment - 1)) != 0) {
            throw new IllegalArgumentException("Invalid alignment for JavaObject should be " + _objectAlignment + " aligned. Address = " + address.toString());
        }
        long arrayletIdentificationBitmask = 0;
        long arrayletIdentificationResult = 0;
        int arrayletIdentificationWidth = 0;
        int arrayletIdentificationOffset = 0;
        int arrayletSpineSize = 0;
        long arrayletLeafSize = 0;
        arrayletIdentificationBitmask = _parentHeap.getArrayletIdentificationBitmask();
        arrayletIdentificationResult = _parentHeap.getArrayletIdentificationResult();
        arrayletIdentificationWidth = _parentHeap.getArrayletIdentificationWidth();
        arrayletIdentificationOffset = _parentHeap.getArrayletIdentificationOffset();
        arrayletSpineSize = getArrayletSpineSize();
        arrayletLeafSize = getArrayletLeafSize();
        boolean isArraylet = false;
        if (0 != arrayletIdentificationResult) {
            // note that this may be an arraylet so we need to do some extra work here
            long maskedFlags = 0;
            if (4 == arrayletIdentificationWidth) {
                try {
                    maskedFlags = 0xFFFFFFFFL & (long) (address.getIntAt(arrayletIdentificationOffset));
                } catch (MemoryAccessException e) {
                    throw new CorruptDataException(new CorruptData("unable to access object flags", address));
                }
            } else if (8 == arrayletIdentificationWidth) {
                try {
                    maskedFlags = address.getLongAt(arrayletIdentificationOffset);
                } catch (MemoryAccessException e) {
                    throw new CorruptDataException(new CorruptData("unable to access object flags", address));
                }
            } else {
                // this size cannot be read without exposing endian of the underlying core
                System.err.println("Arraylet identification width is invalid: " + arrayletIdentificationWidth + " (should be 4 or 8)");
            }
            isArraylet = arrayletIdentificationResult == (arrayletIdentificationBitmask & maskedFlags);
        }
        object = new com.ibm.dtfj.java.j9.JavaObject(_javaVM, address, _parentHeap, arrayletSpineSize, arrayletLeafSize, isArraylet, _objectAlignment);
    }
    return object;
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.j9.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 89 with CorruptDataException

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

the class JavaMonitor method getOwner.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.java.JavaMonitor#getOwner()
	 */
public JavaThread getOwner() throws CorruptDataException {
    JavaThread owningThread = null;
    Iterator allThreads = _javaVM.getThreads();
    while (allThreads.hasNext()) {
        JavaThread oneThread = (JavaThread) allThreads.next();
        if (oneThread.getJNIEnv().getAddress() == _owningThreadID) {
            owningThread = oneThread;
            break;
        }
    }
    if ((null == owningThread) && (0 != _owningThreadID)) {
        // we have an owner but we couldn't find it.  That implies that the XML is corrupt
        throw new CorruptDataException(new CorruptData("Monitor owner not found", _javaVM.pointerInAddressSpace(_owningThreadID)));
    }
    return owningThread;
}
Also used : Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) CorruptData(com.ibm.dtfj.image.j9.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 90 with CorruptDataException

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

the class JavaObject method getPersistentHashcode.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.java.JavaObject#getPersistentHashcode()
	 */
public long getPersistentHashcode() throws DataUnavailable, CorruptDataException {
    // this is a terrible way to do this since we know that it _will_ _break_ in the future.  It is, however, the best that we can do
    if (_javaVM.objectShouldInferHash()) {
        try {
            int flags = ((com.ibm.dtfj.java.j9.JavaAbstractClass) getJavaClass()).readFlagsFromInstance(this);
            // now mask out the non-hash bits, shift and return
            // high 15 bits, omitting most significant
            int twoBytes = flags & 0x7FFF0000;
            long hash = (twoBytes >> 16) | twoBytes;
            return hash;
        } catch (MemoryAccessException e) {
            // if we can't access the memory, the core must be corrupt
            throw new CorruptDataException(new CorruptData("Address in object header but unreadable", _basePointer));
        }
    } else {
        throw new DataUnavailable("Unknown hash strategy for this VM version");
    }
}
Also used : DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptData(com.ibm.dtfj.image.j9.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Aggregations

CorruptDataException (com.ibm.dtfj.image.CorruptDataException)124 JavaObject (com.ibm.dtfj.java.JavaObject)55 Iterator (java.util.Iterator)49 JavaClass (com.ibm.dtfj.java.JavaClass)41 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)39 CorruptData (com.ibm.dtfj.image.CorruptData)26 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)25 ImagePointer (com.ibm.dtfj.image.ImagePointer)19 CorruptData (com.ibm.dtfj.image.j9.CorruptData)17 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)14 ImageSection (com.ibm.dtfj.image.ImageSection)12 ImageThread (com.ibm.dtfj.image.ImageThread)12 JavaThread (com.ibm.dtfj.java.JavaThread)12 ArrayList (java.util.ArrayList)11 ImageProcess (com.ibm.dtfj.image.ImageProcess)9 JavaField (com.ibm.dtfj.java.JavaField)8 JavaReference (com.ibm.dtfj.java.JavaReference)8 LinkedList (java.util.LinkedList)8 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)7 JavaMethod (com.ibm.dtfj.java.JavaMethod)7