CONSTANT_Dynamic bootstrap signature restriction
daniel.smith at oracle.com
Mon Mar 5 19:41:16 UTC 2018
In discussions about future directions for CONSTANT_Dynamic, we've decided it would be helpful to restrict the set of legal bootstrap signatures. The first parameter type would be required to be declared with type MethodHandles.Lookup.
See  for further discussion.
Here's the proposed spec change:
1. _R_ gives a symbolic reference to a bootstrap method handle. The bootstrap method handle is resolved ([188.8.131.52]) to obtain a `reference` to an instance of `java.lang.invoke.MethodHandle`.
Any exception that can be thrown as a result of failure of resolution of a symbolic reference to a method handle can be thrown in this step.
**If _R_ is a symbolic reference to a dynamically-computed constant, then it must be the case that the first parameter type of the `java.lang.invoke.MethodType` of the `java.lang.invoke.MethodHandle` is a `Class` representing the class `java.lang.invoke.MethodHandles$Lookup`. If not, resolution fails with a `BootstrapMethodError`.**
> **In contrast, for historical reasons, a dynamically-computed call site may be resolved using a bootstrap method handle whose first parameter type is `Object` or some other compatible type, as determined by the `invokeWithArguments` invocation described below.**
More information about the valhalla-spec-observers