On Thu, 28 Apr 2022 07:16:05 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> Yes, that seems to be the case, and you are right that it is not something >> that is safe to assume. > > Lookup.defineHiddenClass allows class options to be specified, one of which > is "STRONG" to mean that the hidden class can't unloaded if its defining > loader is reachable. > > A static reference or a reachability fence should work for this test. By default hidden classes are non-strong and can be unloaded when no longer referenced, even if their classloader is still reachable. As you want the hidden class to stick around so it can be reported in the stats then either keep a reference (as you have) or else create it as a STRONG hidden class. ------------- PR: https://git.openjdk.java.net/jdk/pull/8438