// final Field fields[] = cls.getDeclaredFields();
final Field[] fields = fieldInfo.getJdkInstanceFields();
final int len = fields.length;
// AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < len; i++) {
final VmField jnodeField = fieldInfo.getJNodeInstanceField(i);
final Field jdkField = fields[i];
final int modifiers = jnodeField.getModifiers();
if ((modifiers & Modifier.STATIC) != 0) {
throw new BuildException("Static field in instance list");
}
final int fldOffset = offset
+ ((VmInstanceField) jnodeField).getOffset();
if ((jdkField == null)
|| ((modifiers & Modifier.TRANSIENT) != 0)) {
if (jnodeField.isWide()) {
os.set64(fldOffset, 0);
} else if (!jnodeField.isPrimitive()) {
os.setWord(fldOffset, 0);
} else {
switch (jnodeField.getTypeSize()) {
case 1:
os.set8(fldOffset, 0);
break;
case 2:
os.set16(fldOffset, 0);
break;
case 4:
os.set32(fldOffset, 0);
break;
default:
throw new BuildException("Invalid typesize in: " + jnodeField);
}
}
if (debugWriter != null) {
debugWriter.println(jnodeField.getName()
+ " transient: 0");
}
} else if (jnodeField.isPrimitive()) {
final Class<?> fType = jdkField.getType();
if (debugWriter != null) {
debugWriter.println(jdkField.getName() + " "
+ jdkField.get(obj));
}
if (fType == byte.class) {
os.set8(fldOffset, jdkField.getByte(obj));
} else if (fType == boolean.class) {
os.set8(fldOffset, (jdkField.getBoolean(obj)) ? 1 : 0);
} else if (fType == char.class) {
os.set16(fldOffset, jdkField.getChar(obj));
} else if (fType == short.class) {
os.set16(fldOffset, jdkField.getShort(obj));
} else if (fType == int.class) {
os.set32(fldOffset, jdkField.getInt(obj));
} else if (fType == float.class) {
os.set32(fldOffset, Float.floatToIntBits(jdkField
.getFloat(obj)));
} else if (fType == long.class) {
os.set64(fldOffset, jdkField.getLong(obj));
} else if (fType == double.class) {
os.set64(fldOffset, Double.doubleToLongBits(jdkField
.getDouble(obj)));
} else {
throw new BuildException("Unknown primitive class "
+ fType.getName());
}
} else if (jnodeField.isAddressType()) {
final Object value = jdkField.get(obj);
if (value == null) {
os.setWord(fldOffset, 0);
} else if (value instanceof UnboxedObject) {
final UnboxedObject uobj = (UnboxedObject) value;