RFR: 8278123: serviceability/dcmd/vm/ClassLoaderStatsTest.java failing with java.lang.AssertionError: Should have a hidden class

David Holmes dholmes at openjdk.java.net
Thu Apr 28 07:23:51 UTC 2022


On Thu, 28 Apr 2022 07:16:05 GMT, Alan Bateman <alanb at 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


More information about the serviceability-dev mailing list