Question About MethodHandles.findSpecial
John Rose
John.Rose at Sun.COM
Tue May 5 23:04:30 PDT 2009
On May 5, 2009, at 10:48 PM, Fredrik Öhrström wrote:
> So my question was, and still is, :-) , why would you
> call a constructor through a MethodHandle?
It would let you emulate the super(...) call in a language which needs
to make a subclass of some Java class with a non-trivial constructor,
without forcing the language to generate bytecodes for that subclass's
constructor call. It's a pretty small use-case, and the workaround is
pretty reasonable: just generate the bytecodes containing the
invokespecial call. After all, the number of superclass constructors
is much smaller, usually, than the number of overrideable and callable
superclass methods. (Generating bytecodes is a burden on very small
JVMs, but not elsewhere.)
BTW, I just pushed out the first big bundle of Java code changes for
the 292 RI, into OpenJDK proper. The latest version of findSpecial
may be viewed here:
http://hg.openjdk.java.net/jdk7/tl/jdk/file/tip/src/share/classes/java/dyn/MethodHandles.java
-- John
More information about the mlvm-dev
mailing list