mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8199875: Require first parameter type of a condy bootstrap to be Lookup
Reviewed-by: jrose
This commit is contained in:
parent
62c94b1751
commit
d3760023e6
3 changed files with 101 additions and 53 deletions
|
@ -49,6 +49,18 @@ public final class ConstantBootstraps {
|
|||
Object info,
|
||||
// Caller information:
|
||||
Class<?> callerClass) {
|
||||
// Restrict bootstrap methods to those whose first parameter is Lookup
|
||||
// The motivation here is, in the future, to possibly support BSMs
|
||||
// that do not accept the meta-data of lookup/name/type, thereby
|
||||
// allowing the co-opting of existing methods to be used as BSMs as
|
||||
// long as the static arguments can be passed as method arguments
|
||||
MethodType mt = bootstrapMethod.type();
|
||||
if (mt.parameterCount() < 2 ||
|
||||
!MethodHandles.Lookup.class.isAssignableFrom(mt.parameterType(0))) {
|
||||
throw new BootstrapMethodError(
|
||||
"Invalid bootstrap method declared for resolving a dynamic constant: " + bootstrapMethod);
|
||||
}
|
||||
|
||||
// BSMI.invoke handles all type checking and exception translation.
|
||||
// If type is not a reference type, the JVM is expecting a boxed
|
||||
// version, and will manage unboxing on the other side.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue