You may bypass the invokespecial <init>(…)V as a first method invocation within a constructor requirement by launching the JVM with -noverify. As long as you don't do anything stupid in the bytecode it will be just ok and you can call a constructor using indy.
Anyway I confess that disabling verification is probably not what you want ;-) - Julien On Tuesday, June 26, 2012 at 11:59 AM, Rémi Forax wrote: > On 06/26/2012 11:40 AM, Jochen Theodorou wrote: > > Hi all, > > > > just to be sure I understand correctly... afaik there are two things > > invokedynamic cannot do. > > > > (1) calling private methods > > actually I am not sure this is really true. There is a Lookup instance I > > can use to get handles to private methods (afaik), therefore it should > > be possible. Or is there an artificial restriction of some kind? > > > > No restriction, or you need a way to get the proper lookup > or you use reflection to get a j.l.r.Method, call setAccessible(true) > and unreflect it as a MethodHandle (see MethodHandles.unreflect*). > > > > > (2) calling super() > > afaik I cannot generate a call site that replaces the invokeSpecial call > > to a super class constructor. > > > > You can call super.foo() but not super(). > It's because the VM verifies that you should not have access to an > uninitialized object, ie. access to an object before calling super(). > So if you do a super() using a MethodHandle, because it's hidden > by an invokedynamic (or a constant method handle) the VM as no > way to know that this invokedynamic will call the constructor > of the super class, so the verifier will not let you call invokedynamic > on this in a constructor without calling explicitly super() before. > > > > > Am I right about those? > > > > bye blackdrag > > Rémi > > _______________________________________________ > mlvm-dev mailing list > mlvm-dev@openjdk.java.net (mailto:mlvm-dev@openjdk.java.net) > http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev _______________________________________________ mlvm-dev mailing list mlvm-dev@openjdk.java.net http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev