Request for reviews (L): 6939203: JSR 292 needs method handle constants
John Rose
John.Rose at Sun.COM
Tue Mar 30 04:24:47 PDT 2010
6939203: JSR 292 needs method handle constants
Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode.
http://cr.openjdk.java.net/~jrose/6939203/hs-webrev.00
Please review this small JDK change along with it:
http://cr.openjdk.java.net/~jrose/6939203/jdk-webrev.00
In order to compile constant references to method handles and method types, the constant pool structure needs to be able to represent method handle references, and the ldc instruction updated (as it was for Class constants).
This feature completes the role of method handle as a lightweight but dynamic access point to any bytecode operation. Without the ability to perform 'ldc', building a handle to a proposed bytecode level member access is 1-2 orders of magnitude more expensive, requiring a reflective lookup.
-- John
P.S. There is an experimental javac change which allows such constants to be written from within Java programs. Here is the change set for reference:
http://cr.openjdk.java.net/~jrose/6939203/lt-webrev.00
The test file for this change shows the sorts of method handle constants that can be formed:
http://cr.openjdk.java.net/~jrose/6939203/lt-webrev.00/raw_files/new/test/tools/javac/meth/MHLiterals.java
More information about the mlvm-dev
mailing list