< prev index next >

test/hotspot/jtreg/gc/shenandoah/options/TestEnabled.java

Print this page
rev 59879 : [mq]: 8249000


   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 import java.lang.management.GarbageCollectorMXBean;
  25 import java.lang.management.ManagementFactory;
  26 
  27 /*
  28  * @test TestEnabled
  29  * @requires vm.gc.Shenandoah & vm.gc == "null" & !vm.graal.enabled
  30  * @run main/othervm -Dexpected=false -Xmx64m                                                       TestEnabled
  31  * @run main/othervm -Dexpected=true  -Xmx64m -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC TestEnabled
  32  */
  33 
  34 /*
  35  * @test TestEnabledAlready
  36  * @requires vm.gc.Shenandoah & vm.gc == "Shenandoah" & !vm.graal.enabled
  37  * @run main/othervm -Dexpected=true -Xmx64m                                                        TestEnabled
  38  */
  39 public class TestEnabled {
  40 
  41     public static void main(String... args) {
  42         boolean expected = Boolean.getBoolean("expected");
  43         boolean actual = isEnabled();
  44         if (expected != actual) {
  45             throw new IllegalStateException("Error: expected = " + expected + ", actual = " + actual);
  46         }
  47     }
  48 
  49     public static boolean isEnabled() {
  50         for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) {
  51             if (bean.getName().contains("Shenandoah")) {
  52                 return true;
  53             }
  54         }
  55         return false;
  56     }


   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 import java.lang.management.GarbageCollectorMXBean;
  25 import java.lang.management.ManagementFactory;
  26 
  27 /*
  28  * @test TestEnabled
  29  * @requires vm.gc.Shenandoah & vm.gc == "null"
  30  * @run main/othervm -Dexpected=false -Xmx64m                                                       TestEnabled
  31  * @run main/othervm -Dexpected=true  -Xmx64m -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC TestEnabled
  32  */
  33 
  34 /*
  35  * @test TestEnabledAlready
  36  * @requires vm.gc.Shenandoah & vm.gc == "Shenandoah"
  37  * @run main/othervm -Dexpected=true -Xmx64m                                                        TestEnabled
  38  */
  39 public class TestEnabled {
  40 
  41     public static void main(String... args) {
  42         boolean expected = Boolean.getBoolean("expected");
  43         boolean actual = isEnabled();
  44         if (expected != actual) {
  45             throw new IllegalStateException("Error: expected = " + expected + ", actual = " + actual);
  46         }
  47     }
  48 
  49     public static boolean isEnabled() {
  50         for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) {
  51             if (bean.getName().contains("Shenandoah")) {
  52                 return true;
  53             }
  54         }
  55         return false;
  56     }
< prev index next >