@JRubyMethod public static IRubyObject to_java(ThreadContext context, final IRubyObject fromObject, final IRubyObject type) { if ( type.isNil() ) return to_java(context, fromObject); final JavaClass targetType = resolveTargetType(context, type); if ( fromObject instanceof RubyArray ) { return targetType.javaArrayFromRubyArray(context, (RubyArray) fromObject); } return Java.getInstance(context.runtime, fromObject.toJava(targetType.javaClass())); }
@JRubyMethod public static IRubyObject to_java(ThreadContext context, final IRubyObject fromObject, final IRubyObject type) { if ( type.isNil() ) return to_java(context, fromObject); final JavaClass targetType = resolveTargetType(context, type); if ( fromObject instanceof RubyArray ) { return targetType.javaArrayFromRubyArray(context, (RubyArray) fromObject); } return Java.getInstance(context.runtime, fromObject.toJava(targetType.javaClass())); }