JDK-6983708 : JSR 292 local bootstrap methods need extra parameters
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2010-09-09
  • Updated: 2010-09-14
  • Resolved: 2010-09-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Relates :  
Description
JSR 292 defines a minimum set of static information which is provided to a bootstrap method when an invokedynamic instruction is first executed.  This information is the calling class, the method name, and the method type descriptor.

Some uses of JSR 292 technology will require additional static parameters to pass at link time.  It is not practical to pass these parameters dynamically (mixed with non-static parameters).

The most natural way to fix this is to introduce a constant pool entry type which applies a method handle to an argument (or, with nesting, to multiple arguments).

Example:
  Runnable r = #bar();

  //this could translate to:
  ldc MethodHandle #bar
  ldc Runnable.class
  invokevirtual MethodHandles.asInstance

  //or could use static arguments:
  ldc (Apply (MethodHandle #MethodHandles.asInstance)
        (MethodHandle #bar) (Class Runnable))

In the case of a mix of static and dynamic arguments, the above "ldc" would be replaced by an invokedynamic and/or followed by an invokevirtual, to apply the dynamic arguments to the constant constructed statically. 

The current workaround to this limitation builds local private BSMs which contain short code sequences to push the extra constants, and then call an augmented BSM.  This workaround causes an explosion of constant pool entries to support the extra BSMs.  It will be much cheaper (especially in scarce CP entries) to encode the extra constants in CP entries linked to the CONSTANT_InvokeDynamic entry.