Duby dynamic dispatch has landed!

John Rose John.Rose at Sun.COM
Thu Mar 25 11:14:53 PDT 2010


On Mar 25, 2010, at 10:33 AM, Charles Oliver Nutter wrote:

> On Thu, Mar 25, 2010 at 3:16 AM, Attila Szegedi <szegedia at gmail.com> wrote:
>> That's odd. "arguments" is Object[]; spreadArguments is required to unpack these arguments and pass them on to the invoked method.
>> 
>> The dynalang-invoke's own test suites fail quite massively when I make the change, and work without the change (well, sans a bunch of TestSimpleDynamicMethod#testVarArgs...() tests which fail due to a MLVM bug, but that's in unrelated code for vararg method handling). I do only have my last august's version of MLVM though; I might need to re-run the tests with a new MLVM, although, honestly, I'd be surprised if that changed anything since to me, the logic seems okay.
> 
> FWIW, here's the error I was getting. I haven't dug into it much other
> than to remove spreadArguments:
> 
> MethodHandleImpl.java:1104:in `raiseException':
> java.lang.ClassCastException: required class [Ljava.lang.Object; but
> encountered class java.util.Collections$UnmodifiableRandomAccessList
> 	from MethodHandle.java:357:in `invokeVarargs'
> 	from MethodHandles.java:563:in `invoke'
> 	from DynamicLinkerImpl.java:120:in `_relinkAndInvoke'
> 	from FilterGeneric.java:520:in `invoke_C0'
> 	from dynamic.duby:3:in `foo'
> ...

Do you know who is creating the UnmodifiableRandomAccessList?

It looks like it needs a toArray call to create the low-level varargs list.

(It would be nice if the MHs combinators dealt with lists, but they don't at present, at least not in a regular fashion.)

> If you want to give it a shot you just need a JRuby snapshot build
> (ci.jruby.org/snapshots), BiteScript (github.com/headius/bitescript),
> and Duby (github.com/headius.duby). I committed my patched
> dynalang-invoke jar in Duby's javalib dir. javac
> src/org/jruby/duby/DynalangBootstrap.java and run jruby bin/duby <file
> or -e> with appropriate JAVA_OPTS for invokedynamic.

I did some browsing and downloading, but there are too many moving parts to quickly figure out... Sorry!

> Speaking of that...I was surprised there's no baseline bootstrap
> method built into dynalang/invoke. It was a trivial amount of code to
> write, but I can imagine a lot of simple uses of dynalang/invoke will
> just want to use the standard multimethod Java dispatch directly. If I
> put together a patch to include my DynalangBootstrap.java, will you
> accept it? (or maybe I have commit rights and I don't know it?)

No, sorry, you don't at present, but you should have one.  However, to my surprise, you are not on this list, which is the first place your name needs to appear for such things:
  https://sca.dev.java.net/CA_signatories.htm

Send me link to DynalangBootstrap.java.  I browsed a couple obvious places under github.com/headius/duby but didn't see it.  (And there's no download page??)

> P.S. Switch to git :)

)-,;  ~~{ Oh foo, I just learned hg. }

-- John



More information about the mlvm-dev mailing list