< prev index next >
test/gc/shenandoah/TestRefprocSanity.java
Print this page
rev 10790 : [backport] Prefix Shenandoah tests with "Test"
*** 1,7 ****
/*
! * Copyright (c) 2018, Red Hat, Inc. and/or its affiliates.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
--- 1,7 ----
/*
! * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
*** 20,40 ****
* questions.
*
*/
/*
! * @test RefprocSanity
* @summary Test that null references/referents work fine
*
! * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions RefprocSanity
! * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ShenandoahVerify RefprocSanity
! * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahGCHeuristics=aggressive RefprocSanity
*/
import java.lang.ref.*;
! public class RefprocSanity {
static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
static final int WINDOW = 10_000;
static final Reference<MyObject>[] refs = new Reference[WINDOW];
--- 20,41 ----
* questions.
*
*/
/*
! * @test TestRefprocSanity
* @summary Test that null references/referents work fine
+ * @key gc
*
! * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC TestRefprocSanity
! * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:+ShenandoahVerify TestRefprocSanity
! * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive TestRefprocSanity
*/
import java.lang.ref.*;
! public class TestRefprocSanity {
static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
static final int WINDOW = 10_000;
static final Reference<MyObject>[] refs = new Reference[WINDOW];
*** 55,83 ****
rIdx++;
if (rIdx >= WINDOW) {
rIdx = 0;
}
! while (rq.poll() != null) {} // drain
}
}
static Reference<MyObject> select(int v, MyObject ext, ReferenceQueue rq) {
switch (v % 10) {
case 0: return new SoftReference<MyObject>(null);
case 1: return new SoftReference<MyObject>(null, rq);
case 2: return new SoftReference<MyObject>(ext);
case 3: return new SoftReference<MyObject>(ext, rq);
-
case 4: return new WeakReference<MyObject>(null);
case 5: return new WeakReference<MyObject>(null, rq);
case 6: return new WeakReference<MyObject>(ext);
case 7: return new WeakReference<MyObject>(ext, rq);
-
case 8: return new PhantomReference<MyObject>(null, rq);
case 9: return new PhantomReference<MyObject>(ext, rq);
-
default: throw new IllegalStateException();
}
}
static void verifyRefAt(int idx) {
--- 56,81 ----
rIdx++;
if (rIdx >= WINDOW) {
rIdx = 0;
}
! while (rq.poll() != null); // drain
}
}
static Reference<MyObject> select(int v, MyObject ext, ReferenceQueue rq) {
switch (v % 10) {
case 0: return new SoftReference<MyObject>(null);
case 1: return new SoftReference<MyObject>(null, rq);
case 2: return new SoftReference<MyObject>(ext);
case 3: return new SoftReference<MyObject>(ext, rq);
case 4: return new WeakReference<MyObject>(null);
case 5: return new WeakReference<MyObject>(null, rq);
case 6: return new WeakReference<MyObject>(ext);
case 7: return new WeakReference<MyObject>(ext, rq);
case 8: return new PhantomReference<MyObject>(null, rq);
case 9: return new PhantomReference<MyObject>(ext, rq);
default: throw new IllegalStateException();
}
}
static void verifyRefAt(int idx) {
*** 88,96 ****
}
}
static class MyObject {
final int x;
! public MyObject(int x) { this.x = x; }
}
}
--- 86,97 ----
}
}
static class MyObject {
final int x;
!
! public MyObject(int x) {
! this.x = x;
! }
}
}
< prev index next >