How to enumeratorize in 1.6.7 // when will enumeratorize be made public?

It looks like in master, RubyEnumerator.enumeratorize() is public, but
as
of 1.6.7 it is not. I’m wondering what the idiomatic way is to do this?
In
1.6.6 I used “RubyEnumerator.
RubyEnumeratorKernerl.obj_to_enum”, but that is no longer working.

As always, I appreciate the help. Writing jruby libraries in Java is a
brave new world.

My method is the following:

@JRubyMethod
public IRubyObject each(ThreadContext context, Block block) throws

ExecException {
//TODO would like to return an Enumerator, but the necessary
methods are taken?
if (!block.isGiven()) return
RubyEnumerator.RubyEnumeratorKernel.obj_to_enum(context, this);

    getIterator(context).each(context,block);

    return this;
    /*  In a future release of JRuby when enumeratorize is made 

public
(which is planned), should replace the above with the below
if (!block.isGiven()) return
RubyEnumerator.enumeratorize(context.getRuntime(), this, “each”);
*/
}

and the error is below:

Java::JavaLang::NoSuchMethodError:
org.jruby.RubyEnumerator$RubyEnumeratorKernel.obj_to_enum(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;
from
org.apache.pig.scripting.jruby.RubyDataBag.each(RubyDataBag.java:175)
from
org.apache.pig.scripting.jruby.RubyDataBag$INVOKER$i$0$0$each.call(RubyDataBag$INVOKER$i$0$0$each.gen:65535)
from
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrNBlock.call(JavaMethod.java:256)
from
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:292)
from
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:135)
from org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:63)
from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
from org.jruby.ast.RootNode.interpret(RootNode.java:129)
from
org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:98)
from
org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:169)
from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1058)
from org.jruby.RubyKernel.eval(RubyKernel.java:1011)
from
org.jruby.RubyKernel$INVOKER$s$0$3$eval.call(RubyKernel$INVOKER$s$0$3$eval.gen:65535)
from
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:186)
from
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:69)
from
org.jruby.ast.FCallManyArgsNode.interpret(FCallManyArgsNode.java:60)
… 114 levels…
from
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:77)
from
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190)
from
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:179)
from
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
from
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
from
Users.jcoveney.workspace.jruby.bin.jirb.file(/Users/jcoveney/workspace/jruby/bin/jirb:13)
from
Users.jcoveney.workspace.jruby.bin.jirb.load(/Users/jcoveney/workspace/jruby/bin/jirb)
from org.jruby.Ruby.runScript(Ruby.java:732)
from org.jruby.Ruby.runScript(Ruby.java:725)
from org.jruby.Ruby.runNormally(Ruby.java:632)
from org.jruby.Ruby.runFromMain(Ruby.java:481)
from org.jruby.Main.doRunFromMain(Main.java:335)
from org.jruby.Main.internalRun(Main.java:255)
from org.jruby.Main.run(Main.java:221)
from org.jruby.Main.run(Main.java:205)
from org.jruby.Main.main(Main.java:185)ree-1.8.7-2011.03 :005 >
a.flatten
Java::JavaLang::NoSuchMethodError:
org.jruby.RubyEnumerator$RubyEnumeratorKernel.obj_to_enum(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;
from
org.apache.pig.scripting.jruby.RubyDataBag.flattten(RubyDataBag.java:189)
from
org.apache.pig.scripting.jruby.RubyDataBag$INVOKER$i$0$0$flattten.call(RubyDataBag$INVOKER$i$0$0$flattten.gen:65535)
from
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrNBlock.call(JavaMethod.java:256)
from
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:292)
from
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:135)
from org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:63)
from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
from org.jruby.ast.RootNode.interpret(RootNode.java:129)
from
org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:98)
from
org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:169)
from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1058)
from org.jruby.RubyKernel.eval(RubyKernel.java:1011)
from
org.jruby.RubyKernel$INVOKER$s$0$3$eval.call(RubyKernel$INVOKER$s$0$3$eval.gen:65535)
from
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:186)
from
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:282)
from
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:71)
… 116 levels…
from
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:77)
from
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190)
from
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:179)
from
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
from
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
from
Users.jcoveney.workspace.jruby.bin.jirb.file(/Users/jcoveney/workspace/jruby/bin/jirb:13)
from
Users.jcoveney.workspace.jruby.bin.jirb.load(/Users/jcoveney/workspace/jruby/bin/jirb)
from org.jruby.Ruby.runScript(Ruby.java:732)
from org.jruby.Ruby.runScript(Ruby.java:725)
from org.jruby.Ruby.runNormally(Ruby.java:632)
from org.jruby.Ruby.runFromMain(Ruby.java:481)
from org.jruby.Main.doRunFromMain(Main.java:335)
from org.jruby.Main.internalRun(Main.java:255)
from org.jruby.Main.run(Main.java:221)
from org.jruby.Main.run(Main.java:205)

Bump :slight_smile:

2012/2/28 Jonathan C. [email protected]

Just a heads up that the best solution I found was to just use
reflection
to bypass the lack of public on enumeratorize. Thankfully this will only
have to last until 1.7.0.

2012/3/15 Jonathan C. [email protected]

Yeah, sorry for no reply from me I think I’m even the one who made it
public.

We aren’t going to do a 1.6.8, so that’s probably your best option for
now.

  • Charlie

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs