On Wed, 18 Nov 2026 02:56:42 GMT, David Holmes <[email protected]> wrote:

> I don't quite follow the logic here. Isn't it the old proxy classes that you 
> want to be able to reclaim now that they are being replaced by new ones due 
> to the redefinition?

Yes—the obsolete proxy classes are precisely what we want to reclaim. This 
change enables that for subsequent generations. It cannot retroactively remove 
`STRONG_LOADER_LINK` from classes that were already defined with it. Those 
remain retained for the lifetime of their defining loader; for the built-in 
loaders, effectively the lifetime of the JVM.

The distinction is between that initial strongly linked generation and the 
additional generations produced by repeated instrumentation:

1. JFR Method Tracing targets a specific method, instrumenting it through class 
retransformation.
2. Retransformation runs the rewriter over **all methods** of the replacement 
class, including methods whose bytecodes were unchanged. Each `invokedynamic` 
instruction receives a fresh, initially unresolved entry.
3. When execution reaches those sites, resolution invokes their bootstrap 
methods again. Newly generated lambda proxy classes are now defined without 
`STRONG_LOADER_LINK`, because the caller satisfies the redefinition predicate.
4. Stopping tracing retransforms the class again to remove the instrumentation. 
This again replaces the methods and their linkage state. Proxy classes from the 
preceding generation can now unload once they are otherwise unreachable, 
because they were defined without the strong loader link.
5. Further instrumentation cycles follow the same pattern: subsequent obsolete 
generations can be reclaimed.

The initial strongly linked generation remains. This change prevents repeated 
instrumentation from continually adding further generations that must remain 
alive for the lifetime of the loader.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33921#discussion_r4610015848

Reply via email to