RFR: 8297936: Use reachabilityFence to manage liveness in ClassUnload tests
David Holmes
dholmes at openjdk.org
Wed Feb 15 06:19:45 UTC 2023
On Tue, 14 Feb 2023 09:02:09 GMT, Afshin Zafari <duke at openjdk.org> wrote:
> ### Description
> Instead of using static instances or using an object in print to keep it alive, `java.lang.ref.Reference.reachabilityFence(Object)` is used to keep an object alive and avoid class unloading.
>
> ### Tests
> linux-x64-debug, macosx-aarch64-debug, mach5 tier1-5
Changes requested by dholmes (Reviewer).
test/hotspot/jtreg/runtime/ClassUnload/ConstantPoolDependsTest.java line 35:
> 33: * @compile p2/c2.java MyDiffClassLoader.java
> 34: * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
> 35: * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -Xlog:class+unload -Xcomp -XX:+WhiteBoxAPI ConstantPoolDependsTest
As Coleen states, do not force the tests to run in Xcomp mode.
test/hotspot/jtreg/runtime/ClassUnload/KeepAliveObject.java line 68:
> 66: ClassUnloadCommon.failIf(!isAlive, "should be alive");
> 67: }
> 68: Reference.reachabilityFence(o);
Please add comment:
// Don't let `o` get prematurely reclaimed by the GC.
test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java line 52:
> 50: */
> 51: public class UnloadTest {
> 52: // Using a global static field to keep the object live in -Xcomp mode.
This comment needs deleting now.
test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java line 79:
> 77: ClassUnloadCommon.failIf(!wb.isClassAlive(className), "should still be live");
> 78:
> 79: Reference.reachabilityFence(o);
Again add a comment please.
test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java line 108:
> 106: ClassUnloadCommon.failIf(!wb.isClassAlive(className), "should still be live");
> 107:
> 108: Reference.reachabilityFence(o);
Again please add comment.
-------------
PR: https://git.openjdk.org/jdk/pull/12552
More information about the hotspot-runtime-dev
mailing list