< prev index next >

test/hotspot/jtreg/gc/g1/TestPeriodicCollectionJNI.java

Print this page




  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.g1;
  25 
  26 /* @test
  27  * @bug 8218880
  28  * @summary Test that issuing a periodic collection while the GC locker is
  29  * held does not crash the VM.
  30  * @key gc
  31  * @requires vm.gc.G1
  32  * @modules java.base
  33  * @run main/othervm/native
  34  *    -Xbootclasspath/a:.
  35  *    -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  36  *    -XX:+UseG1GC -XX:G1PeriodicGCInterval=100
  37  *    -XX:+G1PeriodicGCInvokesConcurrent
  38  *    -Xlog:gc,gc+periodic=debug
  39  *    gc.g1.TestPeriodicCollectionJNI
  40  * @run main/othervm/native
  41  *    -Xbootclasspath/a:.
  42  *    -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  43  *    -XX:+UseG1GC -XX:G1PeriodicGCInterval=100
  44  *    -XX:-G1PeriodicGCInvokesConcurrent
  45  *    -Xlog:gc,gc+periodic=debug
  46  *    gc.g1.TestPeriodicCollectionJNI
  47  */
  48 
  49 public class TestPeriodicCollectionJNI {
  50     static { System.loadLibrary("TestPeriodicCollectionJNI"); }
  51 
  52     private static native boolean blockInNative(byte[] array);
  53     private static native void unblock();
  54 
  55     public static void block() {
  56         if (!blockInNative(new byte[0])) {
  57             throw new RuntimeException("failed to acquire lock to dummy object");
  58         }
  59     }
  60 
  61     public static void main(String[] args) throws InterruptedException {
  62         long timeout = 2000;
  63         long startTime = System.currentTimeMillis();
  64 
  65         // Start thread doing JNI call




  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.g1;
  25 
  26 /* @test
  27  * @bug 8218880
  28  * @summary Test that issuing a periodic collection while the GC locker is
  29  * held does not crash the VM.
  30  * @key gc
  31  * @requires vm.gc.G1
  32  * @modules java.base
  33  * @run main/othervm/native
  34  *    -Xbootclasspath/a:.
  35  *    -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  36  *    -XX:+UseG1GC -XX:G1PeriodicGCInterval=100
  37  *    -XX:+G1PeriodicGCInvokesConcurrent
  38  *    -Xlog:gc*,gc+periodic=debug
  39  *    gc.g1.TestPeriodicCollectionJNI
  40  * @run main/othervm/native
  41  *    -Xbootclasspath/a:.
  42  *    -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  43  *    -XX:+UseG1GC -XX:G1PeriodicGCInterval=100
  44  *    -XX:-G1PeriodicGCInvokesConcurrent
  45  *    -Xlog:gc*,gc+periodic=debug
  46  *    gc.g1.TestPeriodicCollectionJNI
  47  */
  48 
  49 public class TestPeriodicCollectionJNI {
  50     static { System.loadLibrary("TestPeriodicCollectionJNI"); }
  51 
  52     private static native boolean blockInNative(byte[] array);
  53     private static native void unblock();
  54 
  55     public static void block() {
  56         if (!blockInNative(new byte[0])) {
  57             throw new RuntimeException("failed to acquire lock to dummy object");
  58         }
  59     }
  60 
  61     public static void main(String[] args) throws InterruptedException {
  62         long timeout = 2000;
  63         long startTime = System.currentTimeMillis();
  64 
  65         // Start thread doing JNI call


< prev index next >