HelloUnload.java tests refcount of the Symbol for ClassLoader::getName().
https://github.com/openjdk/jdk/blob/f3da7ff66e83a44118c090b7729dce858f0df1b1/test/hotspot/jtreg/runtime/cds/appcds/customLoader/test-classes/HelloUnload.java#L101
URLClassLoader urlClassLoader =
new URLClassLoader("HelloClassLoader", urls, null);
if (doUnload) {
String loaderName = urlClassLoader.getName();
int loadedRefcount = wb.getSymbolRefcount(loaderName);
System.out.println("Refcount of symbol " + loaderName + " is " + loadedRefcount);
...
int unloadedRefcount = wb.getSymbolRefcount(loaderName);
System.out.println("Refcount of symbol " + loaderName + " is " + unloadedRefcount);
// refcount of a permanent symbol will not be decremented
if (loadedRefcount != 65535) {
ClassUnloadCommon.failIf(unloadedRefcount != (loadedRefcount - 1), "Refcount must be decremented");
}
}
This portion of the test is copied from
https://github.com/openjdk/jdk/blob/f3da7ff66e83a44118c090b7729dce858f0df1b1/test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java#L65
which was introduced in JDK-8210559
However, HelloUnload is archived, so the Symbol for the literal string "HelloClassLoader" is also archived, which means it will always have a refcount of 65535
Output:
class CustomLoadee
java.net.URLClassLoader@2b193f2d
Refcount of symbol HelloClassLoader is 65535
Is CustomLoadee alive? false
Refcount of symbol HelloClassLoader is 65535