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);
}
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();
}
}
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;
}
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;
}
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");
}
}
Aggregations