}
staticRuntime = runtime;
JavaObject theJavaObject=null;
Iterator heaps = runtime.getHeaps().iterator();
JavaClass theJavaClass = null;
while (heaps.hasNext()) {
Object nextHeap = heaps.next();
if (nextHeap instanceof CorruptData) {
System.err.println("returned CorruptData `" + nextHeap + "'");
break;
}
JavaHeap aJavaHeap = (JavaHeap) nextHeap;
Iterator objects = aJavaHeap.getObjects().iterator();
while (objects.hasNext()) {
Object nextObject = objects.next();
if (nextObject instanceof CorruptData) {
System.err.println("returned CorruptData `" + nextObject + "'");
break;
}
JavaObject aJavaObject = (JavaObject) nextObject;
theJavaClass = aJavaObject.getJavaClass();
String theClassName = (theJavaClass).getName();
if (theClassName.equals(SetupJavaObject_arraycopy.TestArraysClassName)){
theJavaObject = aJavaObject;
break;
}
}
}
if (theJavaObject == null) {
fail("Didn't find TestArrays object");
return;
}
Iterator fields = theJavaClass.getDeclaredFields().iterator();
while (fields.hasNext()) {
Object nextField = fields.next();
if (nextField instanceof CorruptData) {
System.err.println("returned CorruptData `" + nextField + "'");
break;
}
JavaField theField = (JavaField) nextField;
String theFieldName = theField.getName();
if(theFieldName.equals("booleanArray")) {
booleanDumpArray = (JavaObject) theField.get(theJavaObject);
} else if(theFieldName.equals("byteArray")) {
byteDumpArray = (JavaObject) theField.get(theJavaObject);
} else if(theFieldName.equals("shortArray")) {
shortDumpArray = (JavaObject) theField.get(theJavaObject);
} else if(theFieldName.equals("charArray")) {
charDumpArray = (JavaObject) theField.get(theJavaObject);
}else if(theFieldName.equals("intArray")) {
intDumpArray = (JavaObject) theField.get(theJavaObject);
} else if(theFieldName.equals("longArray")) {
longDumpArray = (JavaObject) theField.get(theJavaObject);
} else if(theFieldName.equals("floatArray")) {
floatDumpArray = (JavaObject) theField.get(theJavaObject);
} else if(theFieldName.equals("doubleArray")) {
doubleDumpArray = (JavaObject) theField.get(theJavaObject);
} else if(theFieldName.equals("integerArray")) {
integerDumpArray = (JavaObject) theField.get(theJavaObject);
} else if (theFieldName.equals("nonArray")) {
nonDumpArray = (JavaObject) theField.get(theJavaObject);
} else if (theFieldName.equals("arrayArray")) {
arrayDumpArray = (JavaObject) theField.get(theJavaObject);
}
}
// Find the JavaField "value" in "java/lang/Integer"
Iterator classLoaders = getJavaRuntime().getJavaClassLoaders().iterator();
JavaClass integerClass = null;
CLASSLOADERS:
while (classLoaders.hasNext()) {
Object next = classLoaders.next();
if (next instanceof CorruptData) {
throw new Exception("CorruptData found instead of JavaClassLoader");
}
JavaClassLoader loader = (JavaClassLoader) next;
Iterator classes = loader.getDefinedClasses().iterator();
while (classes.hasNext()) {
Object next2 = classes.next();
if (next2 instanceof CorruptData) {
throw new Exception("CorruptData found instead of JavaClass java.lang.Integer");
}
JavaClass aClass = (JavaClass) next2;
if (aClass.getName().equals("java/lang/Integer")) {
integerClass = aClass;
break CLASSLOADERS;
}
}
}