offset = (Long) objectFieldOffset.invoke(unsafe, field);
} catch (Exception e) {
throw new IllegalStateException("Failed getting offset for: field=" + field.getName() + " class=" + field.getDeclaringClass().getName(), e);
}
Class type = field.getType();
try {
if (type.isPrimitive()) {
if (type.equals(Integer.TYPE)) {
putInt.invoke(unsafe, object, offset, ((Integer) value).intValue());
} else if (type.equals(Long.TYPE)) {
putLong.invoke(unsafe, object, offset, ((Long) value).longValue());
} else if (type.equals(Short.TYPE)) {
putShort.invoke(unsafe, object, offset, ((Short) value).shortValue());
} else if (type.equals(Character.TYPE)) {
putChar.invoke(unsafe, object, offset, ((Character) value).charValue());
} else if (type.equals(Byte.TYPE)) {
putByte.invoke(unsafe, object, offset, ((Byte) value).byteValue());
} else if (type.equals(Float.TYPE)) {
putFloat.invoke(unsafe, object, offset, ((Float) value).floatValue());
} else if (type.equals(Double.TYPE)) {
putDouble.invoke(unsafe, object, offset, ((Double) value).doubleValue());
} else if (type.equals(Boolean.TYPE)) {
putBoolean.invoke(unsafe, object, offset, ((Boolean) value).booleanValue());
} else {
throw new IllegalStateException("Unknown primitive type: " + type.getName());
}
} else {
putObject.invoke(unsafe, object, offset, value);
}
} catch (Exception e) {