use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class RootPathCommand method objectToString.
public static String objectToString(J9ObjectPointer object) throws CorruptDataException {
J9ClassPointer clazz = J9ObjectHelper.clazz(object);
StringWriter buf = new StringWriter();
String className;
className = J9ClassHelper.getJavaName(clazz);
if (className.equals("java/lang/Class")) {
buf.write("class ");
buf.write(J9ClassHelper.getJavaName(ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object)));
buf.write('@');
buf.write(object.getHexAddress());
} else if (className.equals("java/lang/String")) {
buf.write('"');
buf.write(J9ObjectHelper.stringValue(object));
buf.write("\"@");
buf.write(object.getHexAddress());
} else {
buf.write(className);
buf.write('@');
buf.write(object.getHexAddress());
if (ObjectModel.isIndexable(object)) {
buf.write(" = ");
buf.write(J9IndexableObjectHelper.getDataAsString(J9IndexableObjectPointer.cast(object)));
}
}
return buf.toString();
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9Class.
private boolean verifyJ9Class(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
boolean passed = verifyJ9ClassHeader(javaVM, out, classPointer);
if (!classPointer.classLoader().isNull()) {
J9MemorySegmentPointer segment = classPointer.classLoader().classSegments();
segment = findSegmentInClassLoaderForAddress(classPointer, segment);
if (segment.isNull()) {
reportError(out, "class=0x%s not found in classLoader=0x%s", Long.toHexString(classPointer.getAddress()), Long.toHexString(classPointer.classLoader().getAddress()));
passed = false;
}
}
if (!verifyJ9ClassSubclassHierarchy(javaVM, out, classPointer)) {
passed = false;
}
return passed;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method checkJ9ROMClassSanity.
/*
* Based on vmchk/checkromclasses.c r1.5
*
* J9ROMClass sanity:
* SRP check:
* Ensure J9ROMClass->interfaces SRP is in the same segment if J9ROMClass->interfaceCount != 0.
* Ensure J9ROMClass->romMethods SRP is in the same segment if J9ROMClass->romMethodCount != 0.
* Ensure J9ROMClass->romFields SRP is in the same segment if J9ROMClass->romFieldCount != 0.
* Ensure J9ROMClass->innerClasses SRP is in the same segment if J9ROMClass->innerClasseCount != 0.
* Ensure cpShapeDescription in the same segment.
* Ensure all SRPs are in range on 64 bit platforms (including className, superclassName, and outerClassName).
*
* ConstantPool count check:
* Ensure ramConstantPoolCount <= romConstantPoolCount
*/
private void checkJ9ROMClassSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
reportMessage(out, "Checking ROM classes");
// Stolen from RootScaner.scanClasses()
// GCClassLoaderIterator gcClassLoaderIterator =
// GCClassLoaderIterator.from();
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
int count = 0;
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
verifyJ9ROMClass(out, vm, clazz);
count++;
}
}
reportMessage(out, "Checking %d ROM classes done", count);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9ClassSubclassHierarchy.
private boolean verifyJ9ClassSubclassHierarchy(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
int index = 0;
UDATA rootDepth = J9ClassHelper.classDepth(classPointer);
J9ClassPointer currentClass = classPointer;
boolean done = false;
while (!done) {
J9ClassPointer nextSubclass = currentClass.subclassTraversalLink();
if (nextSubclass.isNull()) {
reportError(out, "class=0x%s had NULL entry in subclassTraversalLink list at index=%d following class=0x%s", Long.toHexString(classPointer.getAddress()), index, Long.toHexString(currentClass.getAddress()));
return false;
}
/* Sanity check the nextSubclass. */
if (!verifyJ9ClassHeader(javaVM, out, nextSubclass)) {
return false;
}
if (J9ClassHelper.classDepth(nextSubclass).lte(rootDepth)) {
done = true;
} else {
currentClass = nextSubclass;
index++;
}
}
return true;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyClassMethods.
private int verifyClassMethods(J9JavaVMPointer vm, PrintStream out, J9ClassPointer clazz) throws CorruptDataException {
int count = 0;
J9ROMClassPointer romClass = clazz.romClass();
int methodCount = romClass.romMethodCount().intValue();
J9MethodPointer methods = clazz.ramMethods();
boolean isInterfaceClass = J9ROMClassHelper.isInterface(romClass);
J9ConstantPoolPointer ramConstantPool = J9ConstantPoolPointer.cast(clazz.ramConstantPool());
for (int i = 0; i < methodCount; i++) {
J9MethodPointer method = methods.add(i);
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(method);
boolean methodInVTable = J9ROMMethodHelper.hasVTable(romMethod);
if (!findROMMethodInClass(vm, romClass, romMethod, methodCount)) {
reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in romClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!isInterfaceClass && methodInVTable) {
if (!findMethodInVTable(method, clazz)) {
reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in vTable of ramClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(clazz.getAddress()));
}
}
if (!ramConstantPool.eq(ConstantPoolHelpers.J9_CP_FROM_METHOD(method))) {
reportError(out, "ramConstantPool=0x%s on ramMethod=0x%s not equal to ramConstantPool=0x%s on ramClass=0x%s", Long.toHexString(ConstantPoolHelpers.J9_CP_FROM_METHOD(method).getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(ramConstantPool.getAddress()), Long.toHexString(clazz.getAddress()));
}
count++;
}
return count;
}
Aggregations