 }
 
 get_field_from_offset = (rs, cls, offset) ->
+  classname = cls.this_class.toClassString()
   until cls.fields[offset]?
-    throw "field #{offset} doesn't exist in class #{cls.this_class}" unless cls.super_class?
+    unless cls.super_class?
+      util.java_throw rs, 'java/lang/NullPointerException', "field #{offset} doesn't exist in class #{classname}"
     cls = rs.class_lookup(cls.super_class)
   cls.fields[offset]
+
+get_value_from_offset = (rs, obj, offset) ->
+  if obj.type instanceof types.ArrayType
+    return obj.array[offset.toInt()]
+  f = get_field_from_offset rs, rs.class_lookup(obj.type), offset.toInt()
+  return rs.static_get({class:obj.type.toClassString(),name:f.name}) if f.access_flags.static
+  obj.fields[f.name] ? 0
+
+set_value_from_offset = (rs, obj, offset, value) ->
+  o = offset.toInt()
+  if obj.type instanceof types.ArrayType
+    obj.array[o] = value
+  else
+    f = get_field_from_offset rs, rs.class_lookup(obj.type), o
+    if f.access_flags.static
+      rs.push value
+      rs.static_put({class:obj.type.toClassString(),name:f.name})
+    else
+      obj.fields[f.name] = value
 
 stat_file = (fname) ->
   try

        o 'staticFieldBase(Ljava/lang/reflect/Field;)Ljava/lang/Object;', (rs,_this,field) ->
            rs.set_obj rs.get_obj(field.fields.clazz).fields.$type
        o 'getObjectVolatile(Ljava/lang/Object;J)Ljava/lang/Object;', (rs,_this,obj,offset) ->
            f = get_field_from_offset rs, rs.class_lookup(obj.type), offset.toInt()
            return rs.static_get({class:obj.type.toClassString(),name:f.name}) if f.access_flags.static
            obj.fields[f.name] ? 0
        o 'getObject(Ljava/lang/Object;J)Ljava/lang/Object;', (rs,_this,obj,offset) ->
            f = get_field_from_offset rs, rs.class_lookup(obj.type), offset.toInt()
            return rs.static_get({class:obj.type.toClassString(),name:f.name}) if f.access_flags.static
            obj.fields[f.name] ? 0
      ]
    reflect:
      NativeMethodAccessorImpl: [

        o 'open(L!/lang/String;)V', (rs, _this, fname) ->
            jvm_str = rs.jvm2js_str fname
            _this.fields.$file = fs.openSync jvm_str, 'w'
        o 'writeBytes([BIIZ)V', (rs, _this, bytes, offset, len, append) ->
            if _this.fields.$file?
              # appends by default in the browser, not sure in actual node.js impl
              fs.writeSync(_this.fields.$file, new Buffer(bytes.array), offset, len)
              return
            rs.print rs.jvm_carr2js_str(bytes.ref, offset, len)
            if node?
              # For the browser implementation -- the DOM doesn't get repainted
              # unless we give the event loop a chance to spin.
              rs.curr_frame().resume = -> # NOP
              throw new util.YieldException (cb) -> setTimeout(cb, 0)
        o 'writeBytes([BII)V', (rs, _this, bytes, offset, len) ->
            if _this.fields.$file?
              fs.writeSync(_this.fields.$file, new Buffer(bytes.array), offset, len)
