JDK-6754038 : writing libraries in Java for non-Java languages requires support for invokedynamic sites
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2008-09-30
  • Updated: 2010-08-18
  • Resolved: 2010-08-18
Related Reports
Duplicate :  
Relates :  
Description
The runtime support for the typical non-Java language is partially written in Java, just as the runtime support for Java is partially written in system programming languages.  That is, Java is the system programming language for the JVM.

If a language uses invokedynamic and method handles to implement itself, the Java code will need to contain such call sites also.

The solution (as with exotic identifiers) is a simple point-fix to the Java language, to allow Java code to make direct reference to facilities the JVM already supports (as of JSR 292, in the case of this bug).

The key change is to allow signature polymorphism for java.dyn.MethodHandle.invoke and for all (non-Object) methods on java.dyn.Dynamic.  The calls compile directly to invoke instructions with the signature implied by the actual arguments.

Details:
 - the method java.dyn.MethodHandle.invoke(AAA)Object exists, even if not explicitly found
 - the method java.dyn.Dynamic.zzz(AAA)Object always exists, even if not explicitly found
 - the cast (Dynamic)x always succeeds and generates no code (other than primitive boxing)
 - the signature of the implicit method is obtained by erasing actual argument types
 - null arguments are treated as of Object type
 - no implicit conversions are performed on these calls; use a cast if you want conversion

See example implementation and further discussion here:
  http://hg.openjdk.java.net/mlvm/mlvm/langtools/file/tip/meth.patch
  http://hg.openjdk.java.net/mlvm/mlvm/langtools/file/tip/meth.txt

Comments
EVALUATION This and other feature-specific CRs have been superceded by the JSR 292 spec.
18-08-2010