Spread problem with > 10 arguments

Rémi Forax forax at univ-mlv.fr
Sat Jul 4 08:49:50 PDT 2009


The code is different if there is less than 10 argument of more :

see line 795 of sun.dyn.MethodHandleImpl

if (nargs < GuardWithCatch.INVOKES.length) {
            MethodType gtype = type.generic();
            MethodType gcatchType = gtype.insertParameterType(0, 
Throwable.class);
            MethodHandle gtarget = convertArguments(token, target, 
gtype, type, null);
            MethodHandle gcatcher = convertArguments(token, catcher, 
gcatchType, ctype, null);
            MethodHandle gguard = new GuardWithCatch(gtarget, exType, 
gcatcher);
            if (gtarget == null || gcatcher == null || gguard == null)  
return null;
            return convertArguments(token, gguard, type, gtype, null);
        } else {
            MethodType gtype = MethodType.makeGeneric(1);   // oh, oh, 
not an array
            MethodType gcatchType = gtype.insertParameterType(0, 
Throwable.class);
            MethodHandle gtarget = spreadArguments(token, target, gtype, 0);
            MethodHandle gcatcher = spreadArguments(token, catcher, 
gcatchType, 1);
            MethodHandle gguard = new GuardWithCatch(gtarget, exType, 
gcatcher);
            if (gtarget == null || gcatcher == null || gguard == null)  
return null;
            return collectArguments(token, gguard, type, 0, null);
        }

If this the first line of the else is wrong,
it should be :
MethodType gtype = MethodType.makeGeneric(0, true);

It's just a guess, sorry,
I've currently no time to compile because I am not at home and just in 
front of a browser.

Rémi

John Rose a écrit :
> That is an awkward error. For now can you make do with fewer args?
>
> -- John  (on my iPhone)
>
> On Jul 3, 2009, at 4:01 PM, Charles Oliver Nutter  
> <headius at headius.com> wrote:
>
>   
>> I seem to have stumbled onto a problem with some handles and >10 or
>>     
>>> 11 arguments.
>>>       
>> For this code:
>>
>>        System.out.println(target.type());
>>        System.out.println(breakJump.type());
>>        target = MethodHandles.catchException(target,
>> JumpException.BreakJump.class, breakJump);
>>
>> This pair of method types works:
>>
>> (org.jruby.runtime.callsite.CacheEntry, 
>> org.jruby.runtime.ThreadContext, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> java.lang.String, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject,org.jruby.runtime.Block) 
>> org.jruby.runtime.builtin.IRubyObject
>> (org.jruby.exceptions.JumpException 
>> $BreakJump, 
>> org.jruby.runtime.callsite.CacheEntry, 
>> org.jruby.runtime.ThreadContext, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> java.lang.String, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject,org.jruby.runtime.Block) 
>> org.jruby.runtime.builtin.IRubyObject
>>
>> But this pair produces an error:
>>
>> (org.jruby.runtime.callsite.CacheEntry, 
>> org.jruby.runtime.ThreadContext, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> java.lang.String, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject,org.jruby.runtime.Block) 
>> org.jruby.runtime.builtin.IRubyObject
>> (org.jruby.exceptions.JumpException 
>> $BreakJump, 
>> org.jruby.runtime.callsite.CacheEntry, 
>> org.jruby.runtime.ThreadContext, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> java.lang.String, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject, 
>> org.jruby.runtime.builtin.IRubyObject,org.jruby.runtime.Block) 
>> org.jruby.runtime.builtin.IRubyObject
>>
>> Here's the error:
>>
>> Caused by: java.lang.IllegalArgumentException: no restarg in
>> (java.lang.Object)java.lang.Object
>>    at sun.dyn.MethodHandleImpl.newIllegalArgumentException 
>> (MethodHandleImpl.java:841)
>>    at sun.dyn.MethodHandleImpl.spreadArguments(MethodHandleImpl.java: 
>> 484)
>>    at sun.dyn.MethodHandleImpl.makeGuardWithCatch 
>> (MethodHandleImpl.java:806)
>>    at java.dyn.MethodHandles.catchException(MethodHandles.java:1397)
>>    at org.jruby.runtime.invokedynamic.InvokeDynamicSupport.<clinit> 
>> (InvokeDynamicSupport.java:742)
>>    ... 10 more
>>
>> Looks like a bug...I have not had a chance to dig into it.
>>
>> - Charlie
>> _______________________________________________
>> mlvm-dev mailing list
>> mlvm-dev at openjdk.java.net
>> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>>     
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>   




More information about the mlvm-dev mailing list