On Wed, 11 Mar 2026 19:14:19 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/java/lang/invoke/ConstantBootstrap.java line 46:
>> 
>>> 44:  *     if the declaration is an instance method.  The arguments can be
>>> 45:  *     variable-arity.
>>> 46:  * <li>The first argument type is exactly {@link MethodHandles.Lookup}.
>> 
>> Why is there a difference here with CallsiteBootrap for 
>> MethodHandles.Lookup? It looks like the implementation checks assignability 
>> for both.
>
> So indy bootstrap can have `(Object, Object...)` but that's illegal for 
> condy. Condy's 1st arg must be declared exactly `MethodHandles.Lookup`.

That’s because we aspire (some day) to add new signatures for BSMs (maybe even 
indy), where the Lookup is absent, and some other rule applies.

FTR:  It could go either way, towards richer or poorer calling sequences.  
Poorer — If a lookup and/or name and/or type are missing you just supply one 
according to some rule.  Richer (what I prefer) — Allow a single argument which 
replaces all three required arguments; it handles most of the hardwired steps 
in the JVM today — reflectively extracts name, type, and arguments, handles all 
exceptions (for each extraction step).  The reason I prefer this is we can then 
remove the ad hoc rules from the JVMS, and just say, "If a Lookup/name/type are 
supplied (the old way), then it as if the following standard BSM-handler object 
were used instead."  Less complexity in JVMS, more power to the end user.  One 
bit of new power:  The end user can choose to reflectively query the 
ConstantDesc for any or all BSM arguments, instead of today’s policy of forcing 
a resolution of all arguments before BSM invocation (with catastrophic failure 
if there’s an exception on any argument).

Anyway, if we do this stuff, there will be just one place to document it in the 
JDK.  And even today’s rules deserve a JDK javadoc block linked to all the 
BSMs.  So we are improving today, and leaving room for future improvement as 
well.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/30125#discussion_r2920504553

Reply via email to