On Mon, 8 Dec 2025 18:26:19 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/java/lang/invoke/IndirectVarHandle.java line 114:
>> 
>>> 112:         // but checking the signature type of MH mostly works
>>> 113:         return MethodHandle.isReachableFrom(vform.getMethodType(0), cl)
>>> 114:                 && target.isReachableFrom(cl);
>> 
>> Right... one of the filters may also keep a class loader alive. But to check 
>> them, we'd have to eagerly instantiate all of them as well.
>> 
>> FWIW, I don't think this is an issue we can just ignore. If a filter keeps a 
>> class loader alive, we'd still have a problem.
>> 
>> Maybe it's possible to collect all the types involved from the filter when 
>> creating an IndirectVarHandle instead, and save those in a separate list for 
>> this check.
>
> I mean a filter method handle may keep other classes alive in addition to 
> just its types. This is not possible from just checking the types. The vform 
> method type is sufficient, because the types from the filter method type is 
> always in one of the indirect layers.

Also, it’s possible for intermediate `MethodHandle`s used as part of 
`MethodHandle` combinators to refer to types from different class loaders.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28585#discussion_r2602260725

Reply via email to