int numInstanceFields = variablesIn.readInt();
long offset = variablesIn.getStreamPosition();
// log.log(Level.FINEST,"objectID " + Long.toHexString(objectID));
JClass c = nreadClass(classRef);
log.log(Level.FINEST, "Obj id " + Long.toHexString(objectID));
JObject obj = model.getObject(classRef, objectID);
if (obj.isVisited())
return obj; // Prevent reference loop
obj.setVisited(true);
// Calculate how many instance fields the reader can see on the class hierarchy
int instanceFieldCount = 0;
JClass superClass = c;
while (superClass != null) {
for (JField jf : (List<JField>) superClass.getDeclaredFields()) {
if (!jf.staticField)
instanceFieldCount++;
}
superClass = model.getClass(superClass.superClassID);
}
// Check they match the dump files recoard
if (numInstanceFields != instanceFieldCount) {
log.log(Level.FINEST, "Non-matching " + numInstanceFields
+ " found " + instanceFieldCount);
System.exit(0);
}
// Now read in all the references
long instanceRefs[] = new long[instanceFieldCount];
variablesIn.seek(offset);
int countUp = 0;
while (countUp < instanceFieldCount) {
instanceRefs[countUp] = variablesIn.readLong();
countUp++;
}
offset = variablesIn.getStreamPosition();
// Follow the references grabbing the correct jfield for the hierarchy of classes
int fieldCount = 0;
int fieldOffset;
fieldOffset = 0;
superClass = c;
while (superClass != null) {
for (JField jf : (List<JField>) superClass.getDeclaredFields()) {
if (!jf.staticField) {
fieldCount++;
if (instanceRefs[fieldOffset +jf.index] == 0x9999999999999999L){
log.fine("Error, unwritten reference");
}
log.finest("Reading in "+fieldCount);
long position = instanceRefs[fieldOffset + jf.index];
variablesIn.seek(position);
byte type = variablesIn.readByte();
if (type == CJVMTI_OBJECT) {
// Don't follow field references. Instead store a "deferred" reference
// as the field value,
JObject refObj = (JObject) model.getObjectAtAddress(position);
if (refObj == null) {
unresolvedReferences.add(position);
}