< prev index next >

test/hotspot/jtreg/gc/shenandoah/jni/TestJNIGlobalRefs.java

Print this page
@@ -1,7 +1,8 @@
  /*
   * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * 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.

@@ -39,36 +40,55 @@
   * @run main/othervm/native -Xmx1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
   *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
   *      TestJNIGlobalRefs
   */
  
+ /* @test id=generational-verify
+  * @summary Test JNI Global Refs with Shenandoah
+  * @requires vm.gc.Shenandoah
+  *
+  * @run main/othervm/native -Xmx1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
+  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
+  *      -XX:+ShenandoahVerify
+  *      TestJNIGlobalRefs
+  */
+ 
+ /* @test id=generational
+  * @summary Test JNI Global Refs with Shenandoah
+  * @requires vm.gc.Shenandoah
+  *
+  * @run main/othervm/native -Xmx1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
+  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
+  *      TestJNIGlobalRefs
+  */
+ 
  import java.util.Arrays;
  import java.util.Random;
  
  public class TestJNIGlobalRefs {
      static {
          System.loadLibrary("TestJNIGlobalRefs");
      }
  
-     private static final int TIME_MSEC = 120000;
+     private static final long TIME_NSEC = 120L * 1_000_000_000L;
      private static final int ARRAY_SIZE = 10000;
  
      private static native void makeGlobalRef(Object o);
      private static native void makeWeakGlobalRef(Object o);
      private static native Object readGlobalRef();
      private static native Object readWeakGlobalRef();
  
      public static void main(String[] args) throws Throwable {
          seedGlobalRef();
          seedWeakGlobalRef();
-         long start = System.currentTimeMillis();
-         long current = start;
-         while (current - start < TIME_MSEC) {
+         long startNanos = System.nanoTime();
+         long currentNanos = startNanos;
+         while (currentNanos - startNanos < TIME_NSEC) {
              testGlobal();
              testWeakGlobal();
              Thread.sleep(1);
-             current = System.currentTimeMillis();
+             currentNanos = System.nanoTime();
          }
      }
  
      private static void seedGlobalRef() {
          int[] a = new int[ARRAY_SIZE];
< prev index next >