On Wed, 3 Dec 2025 23:41:01 GMT, Chen Liang <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/invoke/VarHandle.java line 2036:
>>
>>> 2034: // from two writes (they must not be tearable)
>>> 2035: private record Adaption(VarHandle vh, MethodHandle mh) {}
>>> 2036: private @Stable Adaption adaption;
>>
>> Is a soft reference needed here? The situation looks similar to
>> `MH.asTypeSoftCache`. It can keep some classes referred by `vh` alive for
>> unnecessarily long.
>
> I don't think we can use a SoftReference here if we need to achieve constant
> folding.
>
> Looking at inline_reference_get0, I think we might introduce another field
> property to trust a reference (potentially in an array) if both that
> reference and the referent within the reference is non-null. I think that
> belongs to a separate RFE. What do you think?
Then it makes sense to limit the caching to safe cases only for now. Otherwise,
it would functionally regress due to a possible memory leak.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28585#discussion_r2587156042