< prev index next >

test/hotspot/jtreg/gc/shenandoah/TestReferenceRefersToShenandoah.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2020, 2023, Oracle and/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.

@@ -46,10 +46,35 @@
   *      -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
   *      -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCMode=satb -XX:ShenandoahGarbageThreshold=100 -Xmx100m
   *      gc.shenandoah.TestReferenceRefersToShenandoah
   */
  
+ /* @test id=generational
+  * @requires vm.gc.Shenandoah
+  * @library /test/lib
+  * @build jdk.test.whitebox.WhiteBox
+  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
+  * @run main/othervm
+  *      -Xbootclasspath/a:.
+  *      -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+  *      -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
+  *      gc.shenandoah.TestReferenceRefersToShenandoah
+  */
+ 
+ /* @test id=generational-100
+  * @requires vm.gc.Shenandoah
+  * @library /test/lib
+  * @build jdk.test.whitebox.WhiteBox
+  * @modules java.base
+  * @run main jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
+  * @run main/othervm
+  *      -Xbootclasspath/a:.
+  *      -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+  *      -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:ShenandoahGarbageThreshold=100 -Xmx100m
+  *      gc.shenandoah.TestReferenceRefersToShenandoah
+  */
+ 
  import java.lang.ref.PhantomReference;
  import java.lang.ref.Reference;
  import java.lang.ref.ReferenceQueue;
  import java.lang.ref.WeakReference;
  import jdk.test.whitebox.WhiteBox;

@@ -97,11 +122,15 @@
  
      private static void gcUntilOld(Object o) throws Exception {
          if (!WB.isObjectInOldGen(o)) {
              WB.fullGC();
              if (!WB.isObjectInOldGen(o)) {
-                 fail("object not promoted by full gc");
+                 // This is just a warning, because failing would
+                 // be overspecifying for generational shenandoah,
+                 // which need not necessarily promote objects upon
+                 // a full GC.
+                 warn("object not promoted by full gc");
              }
          }
      }
  
      private static void gcUntilOld() throws Exception {

@@ -124,10 +153,14 @@
  
      private static void fail(String msg) throws Exception {
          throw new RuntimeException(msg);
      }
  
+     private static void warn(String msg) {
+         System.out.println("Warning: " + msg);
+     }
+ 
      private static void expectCleared(Reference<TestObject> ref,
                                        String which) throws Exception {
          expectNotValue(ref, testObjectNone, which);
          if (!ref.refersTo(null)) {
              fail("expected " + which + " to be cleared");
< prev index next >