*/
private JClass nreadClass() throws IOException {
long id = variablesIn.getStreamPosition();
id--; // Class id/ImagePointer
JClass c = model.getClass(id);
// Prevent reference loops (check if this class is partly filled in)
if (c.classSig != null)
return c;
int modifiers = variablesIn.readInt();
c.modifiers = (short) modifiers;
log.log(Level.FINEST, "mods " + modifiers + " " + c.modifiers);
String name = readUTFString(variablesIn);
String sourceFile = readUTFString(variablesIn);
String genSig = readUTFString(variablesIn);
// TODO move this to C implementation
if (sourceFile.equals("NoSource")) {
if (!(name.indexOf("[")>-1)&&name.indexOf("L")>-1){
sourceFile = name.substring(name.lastIndexOf("/")+1, name.indexOf(";")); // Small attempt to extend number of sourcefiles reported to Eclipse
}
}
c.classSig = name;
c.classid = id;
c.sourceFile = sourceFile;
if (variablesIn.readByte() == CJVMTI_METHOD) {
int num = variablesIn.readInt();
for (int i = 0; i < num; i++) {
nmethodDetails(c);
}
} else {
throw new IOException();
}
if (variablesIn.readByte() == CJVMTI_CLASS_INSTANCE_FIELDS) {
instanceFieldDetails(c);
} else {
throw new IOException();
}
int numStaticFields = 0;
if (variablesIn.readByte() == CJVMTI_CLASS_STATIC_FIELDS) {
numStaticFields = nstaticFieldDetails(c);
} else {
throw new IOException();
}
long supC = 0;
if (variablesIn.readByte() == CJVMTI_SUPERCLASS_FIELDS) {
supC = variablesIn.readLong();
} else {
throw new IOException();
}
long interfaceClasses[];
if (variablesIn.readByte() == CJVMTI_CLASS_INTERFACES) {
int numInterfaces = variablesIn.readInt();
interfaceClasses = new long[numInterfaces];
for (int i = 0; i < interfaceClasses.length; i++) {
interfaceClasses[i] = variablesIn.readLong();
}
} else {
throw new IOException();
}
if (!(variablesIn.readByte() == CJVMTI_CLASS_STATIC_FIELDS)) {
throw new IOException();
}
long refs[] = new long[numStaticFields];
for (int i = 0; i < numStaticFields; i++) {
refs[i] = variablesIn.readLong();
}
long classLoaderRef = 0;
if (variablesIn.readByte() == CJVMTI_CLASSLOADERS) {
classLoaderRef = variablesIn.readLong();
} else {
throw new IOException();
}
c.superClassID = supC;
if (supC != CJVMTI_NULL_OBJECT) {
c.superclass = nreadClass(supC);
}
// Read static field references
for (JField fl : (List<JField>) c.getDeclaredFields()) {
if (fl.staticField) {
fl.staticValue = nreadReference(refs[fl.index]);
}
}
log.log(Level.FINEST, "num interf: " + interfaceClasses.length + " "
+ c.classSig);
// Follow interface references
for (long interfaceRef : interfaceClasses) {
JClass interfaceC = nreadClass(interfaceRef);
c.addInterface(interfaceC);
}
{
JClassLoader jcl = nreadClassLoader(classLoaderRef);