static public enum Type {
BYTE, BOOLEAN, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE, OBJECT
}
static public Object getValue(Object reference, long field, Type type) {
Unsafe unsafe = UnsafeHolder.getUnsafe();
switch (type) {
case BYTE:
return unsafe.getByte(reference, field);
case BOOLEAN:
return unsafe.getBoolean(reference, field);
case CHAR:
return unsafe.getChar(reference, field);
case SHORT:
return unsafe.getShort(reference, field);
case INT:
return unsafe.getInt(reference, field);
case LONG:
return unsafe.getLong(reference, field);
case FLOAT:
return unsafe.getFloat(reference, field);
case DOUBLE:
return unsafe.getDouble(reference, field);
case OBJECT:
return unsafe.getObject(reference, field);
}
return null;
}