1 /*
2 * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package gc.shenandoah;
25
26 /* @test id=satb-100
27 * @requires vm.gc.Shenandoah
28 * @library /test/lib
29 * @build jdk.test.whitebox.WhiteBox
30 * @modules java.base
31 * @run main jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
32 * @run main/othervm
33 * -Xbootclasspath/a:.
34 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
35 * -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCMode=satb -XX:ShenandoahGarbageThreshold=100 -Xmx100m
36 * gc.shenandoah.TestReferenceShortcutCycle
37 */
38
39 import java.lang.ref.PhantomReference;
40 import java.lang.ref.Reference;
41 import java.lang.ref.ReferenceQueue;
42 import java.lang.ref.WeakReference;
43 import jdk.test.whitebox.WhiteBox;
44
45 public class TestReferenceShortcutCycle {
46 private static final int NUM_ITEMS = 100000;
47
48 private static final WhiteBox WB = WhiteBox.getWhiteBox();
49
50 private static final class TestObject {
51 public final int value;
52
53 public TestObject(int value) {
54 this.value = value;
55 }
56 }
57
58 private static WeakReference[] refs;
|
1 /*
2 * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package gc.shenandoah;
25
26 /* @test id=satb-100
27 * @requires vm.gc.Shenandoah
28 * @library /test/lib
29 * @build jdk.test.whitebox.WhiteBox
30 * @modules java.base
31 * @run main jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
32 * @run main/othervm
33 * -Xbootclasspath/a:.
34 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
35 * -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCMode=satb -XX:ShenandoahGarbageThreshold=100 -Xmx100m
36 * gc.shenandoah.TestReferenceShortcutCycle
37 */
38
39 /* @test id=generational-100
40 * @requires vm.gc.Shenandoah
41 * @library /test/lib
42 * @build jdk.test.whitebox.WhiteBox
43 * @modules java.base
44 * @run main jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
45 * @run main/othervm
46 * -Xbootclasspath/a:.
47 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
48 * -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:ShenandoahGarbageThreshold=100 -Xmx100m
49 * gc.shenandoah.TestReferenceShortcutCycle
50 */
51
52 import java.lang.ref.PhantomReference;
53 import java.lang.ref.Reference;
54 import java.lang.ref.ReferenceQueue;
55 import java.lang.ref.WeakReference;
56 import jdk.test.whitebox.WhiteBox;
57
58 public class TestReferenceShortcutCycle {
59 private static final int NUM_ITEMS = 100000;
60
61 private static final WhiteBox WB = WhiteBox.getWhiteBox();
62
63 private static final class TestObject {
64 public final int value;
65
66 public TestObject(int value) {
67 this.value = value;
68 }
69 }
70
71 private static WeakReference[] refs;
|