@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; }
@JRubyMethod public IRubyObject set_static_value(IRubyObject value) { if ( ! ( value instanceof JavaObject ) ) { throw getRuntime().newTypeError("not a java object:" + value); } final Object javaValue = convertValueToJava(value); try { field.set(null, javaValue); } catch (IllegalAccessException iae) { throw getRuntime().newTypeError( "illegal access on setting static 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_static_value(IRubyObject value) { if ( ! ( value instanceof JavaObject ) ) { throw getRuntime().newTypeError("not a java object:" + value); } final Object javaValue = convertValueToJava(value); try { field.set(null, javaValue); } catch (IllegalAccessException iae) { throw getRuntime().newTypeError( "illegal access on setting static variable: " + iae.getMessage()); } catch (IllegalArgumentException iae) { throw getRuntime().newTypeError("wrong type for " + field.getType().getName() + ": " + ( javaValue == null ? null : javaValue.getClass().getName() ) ); } return value; }