示例#1
0
 @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));
   }
 }
示例#2
0
  @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()));
    }
  }
示例#3
0
 @JRubyMethod(name = "hadoop")
 public IRubyObject hadoop(final ThreadContext ctx) {
   return Java.getInstance(ctx.runtime, NullWritable.get());
 }