< prev index next >
test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java
Print this page
*** 21,38 ****
* questions.
*/
/*
* @test UnloadTest
* @requires vm.opt.final.ClassUnloading
* @modules java.base/jdk.internal.misc
* @library /runtime/testlibrary /test/lib
* @library classes
* @build sun.hotspot.WhiteBox test.Empty
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
! * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI UnloadTest
*/
import sun.hotspot.WhiteBox;
/**
* Test that verifies that classes are unloaded when they are no longer reachable.
--- 21,39 ----
* questions.
*/
/*
* @test UnloadTest
+ * @bug 8210559
* @requires vm.opt.final.ClassUnloading
* @modules java.base/jdk.internal.misc
* @library /runtime/testlibrary /test/lib
* @library classes
* @build sun.hotspot.WhiteBox test.Empty
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
! * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xlog:class+unload=debug UnloadTest
*/
import sun.hotspot.WhiteBox;
/**
* Test that verifies that classes are unloaded when they are no longer reachable.
*** 58,67 ****
--- 59,76 ----
Class<?> c = cl.loadClass(className);
Object o = c.newInstance();
ClassUnloadCommon.failIf(!wb.isClassAlive(className), "should be live here");
+ String loaderName = cl.getName();
+ int loadedRefcount = wb.getSymbolRefcount(loaderName);
+ System.out.println("Refcount of symbol " + loaderName + " is " + loadedRefcount);
+
cl = null; c = null; o = null;
ClassUnloadCommon.triggerUnloading();
ClassUnloadCommon.failIf(wb.isClassAlive(className), "should have been unloaded");
+
+ int unloadedRefcount = wb.getSymbolRefcount(loaderName);
+ System.out.println("Refcount of symbol " + loaderName + " is " + unloadedRefcount);
+ ClassUnloadCommon.failIf(unloadedRefcount != (loadedRefcount - 1), "Refcount must be decremented");
}
}
< prev index next >