What can we improve in JSR292 for Java 9?

Jochen Theodorou blackdrag at gmx.org
Thu Mar 5 03:09:59 UTC 2015


Am 04.03.2015 23:50, schrieb Charles Oliver Nutter:
> On Thu, Feb 26, 2015 at 4:27 AM, Jochen Theodorou <blackdrag at gmx.org> wrote:
>> my biggest request: allow the call of a super constructor (like
>> super(foo,bar)) using MethodHandles an have it understood by the JVM like a
>> normal super constructor call... same for this(...)
>
> Just so I understand...the problem is that unless you can get a Lookup
> that can do the super call from Java (i.e. from within a subclass),
> you can't get a handle that can do the super call, right? And you
> can't do that because the method bodies might not be emitted into a
> natural subclass of the super class?

Not fully right. Sorry for the possibly false flag with the permissions 
from the runtime. I am in a natural subclass. Take this pseudoexample:

public class Foo {
   public Foo(String s, Integer i){}
   public Foo(Integer s, Object o){}
}

public class Bar extends Foo {
   public Bar(def a, def b) {
      super(a,b) // call with runtime types here
   }
}

I cannot express super(a,b) using method handles, even if I did know the 
types at compiletime (in which case I would not need invokedynamic 
anyway). Sure, there is 
http://docs.oracle.com/javase/7/docs/api/java/lang/invoke/MethodHandles.Lookup.html#findSpecial%28java.lang.Class,%20java.lang.String,%20java.lang.invoke.MethodType,%20java.lang.Class%29 
but this is for calling methods in a invokespecial like manner, <init> 
is excluded here as stated in the comment. The comment refers to 
findConsructor for calls to constructors, and indeed we have 
invokeSpecial calls there as well, but those are for what in Java is 
"new", and are different from calls to a super constructor. See also 
http://mail.openjdk.java.net/pipermail/mlvm-dev/2012-June/004650.html 
from almost 3 years ago here on the list. Remi gives here a good reason 
why it probably cannot be done easily... in that or an even older thread 
someone (I think John) was talking about security.

bye Jochen

-- 
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org



More information about the mlvm-dev mailing list