@JRubyMethod public IRubyObject value(ThreadContext context, IRubyObject object) { final Ruby runtime = context.runtime; final Object javaObject; if ( ! Modifier.isStatic( field.getModifiers() ) ) { javaObject = unwrapJavaObject(object); } else { javaObject = null; } try { return convertToRuby(runtime, field.get(javaObject)); } catch (IllegalAccessException iae) { throw runtime.newTypeError("illegal access"); } }
@JRubyMethod public IRubyObject value(ThreadContext context, IRubyObject object) { final Ruby runtime = context.runtime; final Object javaObject; if ( ! Modifier.isStatic( field.getModifiers() ) ) { javaObject = unwrapJavaObject(object); } else { javaObject = null; } try { return convertToRuby(runtime, field.get(javaObject)); } catch (IllegalAccessException iae) { throw runtime.newTypeError("illegal access"); } }
@JRubyMethod public IRubyObject set_value(IRubyObject object, IRubyObject value) { final Object javaObject; if ( ! Modifier.isStatic( field.getModifiers() ) ) { javaObject = unwrapJavaObject(object); } else { javaObject = null; } final Object javaValue = convertValueToJava(value); try { field.set(javaObject, javaValue); } catch (IllegalAccessException iae) { throw getRuntime().newTypeError("illegal access on setting variable: " + iae.getMessage()); } catch (IllegalArgumentException iae) { throw getRuntime().newTypeError("wrong type for " + field.getType().getName() + ": " + ( javaValue == null ? null : javaValue.getClass().getName() ) ); } return value; }
@JRubyMethod public IRubyObject set_value(IRubyObject object, IRubyObject value) { final Object javaObject; if ( ! Modifier.isStatic( field.getModifiers() ) ) { javaObject = unwrapJavaObject(object); } else { javaObject = null; } final Object javaValue = convertValueToJava(value); try { field.set(javaObject, javaValue); } catch (IllegalAccessException iae) { throw getRuntime().newTypeError("illegal access on setting variable: " + iae.getMessage()); } catch (IllegalArgumentException iae) { throw getRuntime().newTypeError("wrong type for " + field.getType().getName() + ": " + ( javaValue == null ? null : javaValue.getClass().getName() ) ); } return value; }