changeset 10096:41c72c1fe11f

8149076: [JVMCI] missing ResourceMark in JVMCIRuntime::initialize_HotSpotJVMCIRuntime Reviewed-by: twisti, iignatyev
author never
date Fri, 05 Feb 2016 12:27:02 -0800
parents 52c440e4596f
children 219b7048c2b6
files src/share/vm/jvmci/jvmciRuntime.cpp test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java
diffstat 2 files changed, 26 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Fri Feb 05 18:24:41 2016 +0000
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Fri Feb 05 12:27:02 2016 -0800
@@ -634,6 +634,7 @@
 
 void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
   if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) {
+    ResourceMark rm;
 #ifdef ASSERT
     // This should only be called in the context of the JVMCI class being initialized
     TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/runtime/JVMCI", CHECK);
--- a/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java	Fri Feb 05 18:24:41 2016 +0000
+++ b/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java	Fri Feb 05 12:27:02 2016 -0800
@@ -35,6 +35,16 @@
  *      -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false
  *      -XX:-EnableJVMCI
  *      compiler.jvmci.JVM_GetJVMCIRuntimeTest
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions
+ *      -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true
+ *      -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true
+ *      -XX:+EnableJVMCI
+ *      compiler.jvmci.JVM_GetJVMCIRuntimeTest
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions
+ *      -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false
+ *      -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true
+ *      -XX:-EnableJVMCI
+ *      compiler.jvmci.JVM_GetJVMCIRuntimeTest
 
  */
 
@@ -43,22 +53,27 @@
 import jdk.vm.ci.runtime.JVMCI;
 import jdk.test.lib.Asserts;
 
-import java.lang.reflect.Method;
-
-public class JVM_GetJVMCIRuntimeTest {
+public class JVM_GetJVMCIRuntimeTest implements Runnable {
     private static final boolean IS_POSITIVE = Boolean.getBoolean(
             "compiler.jvmci.JVM_GetJVMCIRuntimeTest.positive");
+    private static final boolean IN_THREAD = Boolean.getBoolean(
+            "compiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded");
 
-    private final Method initializeRuntime;
-
-    public static void main(String[] args) {
-        new JVM_GetJVMCIRuntimeTest().runTest();
+    public static void main(String[] args) throws Throwable {
+        JVM_GetJVMCIRuntimeTest instance = new JVM_GetJVMCIRuntimeTest();
+        if (IN_THREAD) {
+            Thread t = new Thread(instance);
+            t.start();
+            t.join();
+        } else {
+            instance.run();
+        }
     }
 
-    private void runTest() {
+    public void run() {
         Object result;
         try {
-            result = invoke();
+            result = JVMCI.getRuntime();
         } catch (InternalError e) {
             if (IS_POSITIVE) {
                 throw new AssertionError("unexpected exception", e);
@@ -70,28 +85,8 @@
         }
         Asserts.assertNotNull(result,
                 "initializeRuntime returned null");
-        Asserts.assertEQ(result, invoke(),
+        Asserts.assertEQ(result, JVMCI.getRuntime(),
                 "initializeRuntime returns different results");
 
     }
-    private Object invoke() {
-        Object result;
-        try {
-            result = initializeRuntime.invoke(JVMCI.class);
-        } catch (ReflectiveOperationException e) {
-            throw new Error("can't invoke initializeRuntime", e);
-        }
-        return result;
-    }
-
-    private JVM_GetJVMCIRuntimeTest() {
-        Method method;
-        try {
-            method = JVMCI.class.getDeclaredMethod("initializeRuntime");
-            method.setAccessible(true);
-        } catch (NoSuchMethodException e) {
-            throw new Error("can't find JVMCI::initializeRuntime", e);
-        }
-        initializeRuntime = method;
-    }
 }