use of com.ibm.j9ddr.vm29.view.dtfj.java.DTFJJavaObject in project openj9 by eclipse.
the class DTFJJavaObject method arraycopy.
public void arraycopy(int srcStart, Object dst, int dstStart, int length) throws CorruptDataException, MemoryAccessException {
fetchDeferredData();
if (!objectIsArray) {
throw new IllegalArgumentException("Object is not an array");
}
J9IndexableObjectPointer array = J9IndexableObjectPointer.cast(object);
try {
validateArrayCopyParameters(array, srcStart, dst, dstStart, length);
// CMVC 171150 : use helper object to correctly get the class name
String className = J9IndexableObjectHelper.getClassName(array);
if ((null == className) || (className.length() < 2)) {
J9DDRCorruptData cd = new J9DDRCorruptData(DTFJContext.getProcess(), "The class name for this object could not be determined", object.getAddress());
throw new CorruptDataException(cd);
}
if (className.charAt(1) == 'L' || className.charAt(1) == '[') {
// JExtract/DTFJ can cope with dst of either Object[] or JavaObject[] - but we need to detect other things
if (!dst.getClass().equals(Object[].class) && !(dst instanceof JavaObject[])) {
throw new IllegalArgumentException("Type of dst object (" + dst.getClass().getName() + ") incompatible with Object array. Should be JavaObject[] or Object[]");
}
J9ObjectPointer[] intermediateArray = new J9ObjectPointer[length];
Object[] castedDst = (Object[]) dst;
if (dstStart + (long) length > castedDst.length) {
throw new ArrayIndexOutOfBoundsException("Supplied destination array too small. Requires: " + (dstStart + (long) length) + ", was " + castedDst.length);
}
J9IndexableObjectHelper.getData(array, intermediateArray, srcStart, length, 0);
for (int i = 0; i < length; i++) {
if (intermediateArray[i].isNull()) {
castedDst[dstStart + i] = null;
} else {
castedDst[dstStart + i] = new DTFJJavaObject(intermediateArray[i]);
}
}
} else {
// For primitives we can pass through the client object. The type verification will be done in J9IndexableObjectPointer
J9IndexableObjectHelper.getData(array, dst, srcStart, length, dstStart);
}
} catch (Throwable t) {
throw J9DDRDTFJUtils.handleAllButMemAccExAsCorruptDataException(DTFJContext.getProcess(), t, whitelist);
}
}
use of com.ibm.j9ddr.vm29.view.dtfj.java.DTFJJavaObject in project openj9 by eclipse.
the class DTFJJavaFieldInstance method get.
public Object get(JavaObject object) throws CorruptDataException, MemoryAccessException {
if (null == object) {
throw new NullPointerException("JavaObject is null");
}
try {
switch(getSigFlag()) {
case BOOLEAN_SIGNATURE:
return Boolean.valueOf(getBoolean(object));
case BYTE_SIGNATURE:
return Byte.valueOf(getByte(object));
case CHAR_SIGNATURE:
return Character.valueOf(getChar(object));
case SHORT_SIGNATURE:
return Short.valueOf(getShort(object));
case INTEGER_SIGNATURE:
return Integer.valueOf(getInt(object));
case FLOAT_SIGNATURE:
return new Float(getFloat(object));
case LONG_SIGNATURE:
return Long.valueOf(getLong(object));
case DOUBLE_SIGNATURE:
return new Double(getDouble(object));
case ARRAY_PREFIX_SIGNATURE:
case OBJECT_PREFIX_SIGNATURE:
J9ROMFieldShapePointer fieldShape = fieldOffset.getField();
DTFJJavaObject jobj = validateJavaObject(object);
checkDataTypeConversion(jobj, FIELD_OBJECT | FIELD_ARRAY);
J9ObjectPointer data = J9ObjectHelper.getObjectField(jobj.getJ9ObjectPointer(), fieldOffset);
if (data.isNull()) {
return null;
} else {
return new DTFJJavaObject(null, data);
}
default:
throw new IllegalArgumentException("Cannot determine the correct data type");
}
} catch (Throwable t) {
// the whitelist will cause IllegalArgumentException to be re-thrown
throw J9DDRDTFJUtils.handleAllButMemAccExAsCorruptDataException(DTFJContext.getProcess(), t, whitelist);
}
}
use of com.ibm.j9ddr.vm29.view.dtfj.java.DTFJJavaObject in project openj9 by eclipse.
the class DTFJConstantPoolIterator method next.
public Object next() {
if (hasNext()) {
Object retval = null;
if (!EOIObjects) {
// if there are some more items to retrieve from the pool
try {
// register this class for notifications
register(this);
// get the next item
retval = new DTFJJavaObject(poolObjects.next());
// see if there are any more
EOIObjects = !poolObjects.hasNext();
} finally {
// remove notifier registration
unregister(this);
}
return retval;
}
if (!EOIClasses) {
// if there are some more items to retrieve from the pool
try {
// register this class for notifications
register(this);
try {
// DTFJ returns the java.lang.Class object associated with this class
// get the next item
retval = new DTFJJavaObject(poolClasses.next().classObject());
} catch (CorruptDataException e) {
// return the corrupt data
retval = J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), e);
}
// see if there are any more
EOIClasses = !poolClasses.hasNext();
} finally {
// remove notifier registration
unregister(this);
}
return retval;
}
if (cdata != null) {
// there are no more items in the pool
// but there may be corrupt data items to return
retval = cdata;
cdata = null;
}
return retval;
}
throw new NoSuchElementException("There are no more elements in this iterator");
}
Aggregations