@JRubyMethod public static IRubyObject to_java(ThreadContext context, IRubyObject fromObject) { if (fromObject instanceof RubyArray) { return context .runtime .getJavaSupport() .getObjectJavaClass() .javaArrayFromRubyArray(context, fromObject); } else { return Java.getInstance(context.runtime, fromObject.toJava(Object.class)); } }
@JRubyMethod public static IRubyObject to_java( ThreadContext context, IRubyObject fromObject, IRubyObject type) { if (type.isNil()) { return to_java(context, fromObject); } Ruby runtime = context.runtime; JavaClass targetType = getTargetType(context, runtime, type); if (fromObject instanceof RubyArray) { return targetType.javaArrayFromRubyArray(context, fromObject); } else { return Java.getInstance(runtime, fromObject.toJava(targetType.javaClass())); } }
@JRubyMethod(name = "hadoop") public IRubyObject hadoop(final ThreadContext ctx) { return Java.getInstance(ctx.runtime, NullWritable.get()); }