return new OPT_ObjectConstantOperand(field.getObjectValueUnchecked(obj), Offset.zero());
Object value = field.getObjectValueUnchecked(obj); if (value != null) { return new OPT_ObjectConstantOperand(value, Offset.zero()); } else { return new OPT_NullConstantOperand(); }
  public static OPT_ConstantOperand getFieldValueAsConstant(VM_Field field, Object obj) throws NoSuchFieldException {    VM_TypeReference type = field.getType();    if (VM.runningVM) {      if(type.isReferenceType() && !type.isMagicType()) {        return new OPT_ObjectConstantOperand(field.getObjectValueUnchecked(obj), Offset.zero());      }      else if(type.isIntType()) {        return new OPT_IntConstantOperand(field.getIntValueUnchecked(obj));      }      else if(type.isBooleanType()) {        return new OPT_IntConstantOperand(field.getBooleanValueUnchecked(obj) ? 1 : 0);      }      else if(type.isByteType()) {        return new OPT_IntConstantOperand(field.getByteValueUnchecked(obj));      }      else if(type.isCharType()) {        return new OPT_IntConstantOperand(field.getCharValueUnchecked(obj));      }      else if(type.isDoubleType()) {        return new OPT_DoubleConstantOperand(field.getDoubleValueUnchecked(obj));      }      else if(type.isFloatType()) {        return new OPT_FloatConstantOperand(field.getFloatValueUnchecked(obj));      }      else if(type.isLongType()) {        return new OPT_LongConstantOperand(field.getLongValueUnchecked(obj));      }      else if(type.isShortType()) {        return new OPT_IntConstantOperand(field.getShortValueUnchecked(obj));      }      else {        OPT_OptimizingCompilerException.UNREACHABLE("Unknown type " + type);        return null;      }    }    else {      try {        String cn = field.getDeclaringClass().toString();        Field f = Class.forName(cn).getDeclaredField(field.getName().toString());        f.setAccessible(true);        if(type.isReferenceType() && !type.isMagicType()) {          return new OPT_ObjectConstantOperand(f.get(obj), Offset.zero());        }        else if(type.isIntType()) {          return new OPT_IntConstantOperand(f.getInt(obj));        }        else if(type.isBooleanType()) {          return new OPT_IntConstantOperand(f.getBoolean(obj) ? 1 : 0);        }        else if(type.isByteType()) {          return new OPT_IntConstantOperand(f.getByte(obj));        }        else if(type.isCharType()) {          return new OPT_IntConstantOperand(f.getChar(obj));        }        else if(type.isDoubleType()) {          return new OPT_DoubleConstantOperand(f.getDouble(obj));        }        else if(type.isFloatType()) {          return new OPT_FloatConstantOperand(f.getFloat(obj));        }        else if(type.isLongType()) {          return new OPT_LongConstantOperand(f.getLong(obj));        }        else if(type.isShortType()) {          return new OPT_IntConstantOperand(f.getShort(obj));        }        else {          OPT_OptimizingCompilerException.UNREACHABLE("Unknown type " + type);          return null;        }      } catch (IllegalArgumentException e) {        throw new NoSuchFieldException(field.toString());      } catch (IllegalAccessException e) {        throw new NoSuchFieldException(field.toString());      } catch (NoSuchFieldError e) {        throw new NoSuchFieldException(field.toString());      } catch (ClassNotFoundException e) {        throw new NoSuchFieldException(field.toString());      } catch (NoClassDefFoundError e) {        throw new NoSuchFieldException(field.toString());      } catch (ExceptionInInitializerError e) {        throw new NoSuchFieldException(field.toString());            }    }  }