use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class J9ObjectStructureFormatter method format.
@Override
public FormatWalkResult format(String type, long address, PrintStream out, Context context, List<IFieldFormatter> fieldFormatters, String[] extraArgs) {
if (type.equalsIgnoreCase("j9object") || type.equalsIgnoreCase("j9indexableobject")) {
J9ClassPointer clazz = null;
J9ObjectPointer object = null;
try {
boolean isArray;
String className;
object = J9ObjectPointer.cast(address);
clazz = J9ObjectHelper.clazz(object);
if (clazz.isNull()) {
out.println("<can not read RAM class address>");
return FormatWalkResult.STOP_WALKING;
}
isArray = J9ClassHelper.isArrayClass(clazz);
className = J9UTF8Helper.stringValue(clazz.romClass().className());
U8Pointer dataStart = U8Pointer.cast(object).add(ObjectModel.getHeaderSize(object));
if (className.equals("java/lang/String")) {
formatStringObject(out, 0, clazz, dataStart, object);
} else if (isArray) {
int begin = DEFAULT_ARRAY_FORMAT_BEGIN;
int end = DEFAULT_ARRAY_FORMAT_END;
if (extraArgs.length > 0) {
begin = Integer.parseInt(extraArgs[0]);
}
if (extraArgs.length > 1) {
end = Integer.parseInt(extraArgs[1]);
}
formatArrayObject(out, clazz, dataStart, J9IndexableObjectPointer.cast(object), begin, end);
} else {
formatObject(out, clazz, dataStart, object);
}
} catch (MemoryFault ex2) {
out.println("Unable to read object clazz at " + object.getHexAddress() + " (clazz = " + clazz.getHexAddress() + ")");
} catch (CorruptDataException ex) {
out.println("Error for ");
ex.printStackTrace(out);
}
return FormatWalkResult.STOP_WALKING;
} else {
return FormatWalkResult.KEEP_WALKING;
}
}
Aggregations