Path: blob/master/test/hotspot/jtreg/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java
41149 views
/*1* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 813642126* @requires vm.jvmci27* @library /test/lib /28* @modules java.base/jdk.internal.misc29* @modules jdk.internal.vm.ci/jdk.vm.ci.runtime30* @run main/othervm -XX:+UnlockExperimentalVMOptions31* -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true32* -XX:+EnableJVMCI33* compiler.jvmci.JVM_GetJVMCIRuntimeTest34* @run main/othervm -XX:+UnlockExperimentalVMOptions35* -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false36* -XX:-EnableJVMCI -XX:-UseJVMCICompiler37* compiler.jvmci.JVM_GetJVMCIRuntimeTest38* @run main/othervm -XX:+UnlockExperimentalVMOptions39* -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true40* -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true41* -XX:+EnableJVMCI42* compiler.jvmci.JVM_GetJVMCIRuntimeTest43* @run main/othervm -XX:+UnlockExperimentalVMOptions44* -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false45* -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true46* -XX:-EnableJVMCI -XX:-UseJVMCICompiler47* compiler.jvmci.JVM_GetJVMCIRuntimeTest4849*/5051package compiler.jvmci;5253import jdk.test.lib.Asserts;54import jdk.vm.ci.runtime.JVMCI;5556public class JVM_GetJVMCIRuntimeTest implements Runnable {57private static final boolean IS_POSITIVE = Boolean.getBoolean(58"compiler.jvmci.JVM_GetJVMCIRuntimeTest.positive");59private static final boolean IN_THREAD = Boolean.getBoolean(60"compiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded");6162public static void main(String[] args) throws Throwable {63JVM_GetJVMCIRuntimeTest instance = new JVM_GetJVMCIRuntimeTest();64if (IN_THREAD) {65Thread t = new Thread(instance);66t.start();67t.join();68} else {69instance.run();70}71}7273public void run() {74Object result;75try {76result = JVMCI.getRuntime();77} catch (InternalError e) {78if (IS_POSITIVE) {79throw new AssertionError("unexpected exception", e);80}81return;82}83if (!IS_POSITIVE) {84throw new AssertionError("didn't get expected exception");85}86Asserts.assertNotNull(result,87"initializeRuntime returned null");88Asserts.assertEQ(result, JVMCI.getRuntime(),89"initializeRuntime returns different results");9091}92}939495