On Tue, 11 Jul 2023 17:07:00 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>  Just to be clear, the test should pass even if it keeps Lookup as the 
> referent, right?

No. The test will not because there's no reference to the `Lookup` except in 
`asInterfaceInstance` itself; the `Lookup`s thus are always eligible for GC, 
even if there's living wrapper instance, as shown in the first broken 
`assertTrue(cl.referTo(c2.getClass()))` test. The `Class` object for 
implementation, however, is always reachable as long as any wrapper instance is 
reachable.

The alternative to keeping Classes in weak reference is to keep a lookup in the 
hidden class and cache that particular lookup, which IMO only complicates both 
the support code (have to distinguish from `Lookup` returned by 
`defineHiddenClass` and edit spinned bytecode).

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

PR Comment: https://git.openjdk.org/jdk/pull/13197#issuecomment-1631281648

Reply via email to