changeset 13594:143019ae96f5

8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError Reviewed-by: kvn, iveresov
author dnsimon
date Wed, 23 Aug 2017 23:38:06 +0200
parents f59d7a871cb5
children 9cf835fba355 c3e39d67f6d4
files src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java test/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java test/compiler/jvmci/compilerToVM/GetImplementorTest.java test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java test/compiler/jvmci/compilerToVM/ResolveMethodTest.java
diffstat 10 files changed, 31 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Wed Aug 23 23:38:06 2017 +0200
@@ -153,9 +153,9 @@
      * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will
      *            either return a {@link ResolvedJavaType} or throw an exception
      * @return the type for {@code name} or 0 if resolution failed and {@code resolve == false}
-     * @throws LinkageError if {@code resolve == true} and the resolution failed
+     * @throws ClassNotFoundException if {@code resolve == true} and the resolution failed
      */
-    native HotSpotResolvedObjectTypeImpl lookupType(String name, Class<?> accessingClass, boolean resolve);
+    native HotSpotResolvedObjectTypeImpl lookupType(String name, Class<?> accessingClass, boolean resolve) throws ClassNotFoundException;
 
     /**
      * Resolves the entry at index {@code cpi} in {@code constantPool} to an object.
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Aug 23 23:38:06 2017 +0200
@@ -367,13 +367,17 @@
 
         // Resolve non-primitive types in the VM.
         HotSpotResolvedObjectTypeImpl hsAccessingType = (HotSpotResolvedObjectTypeImpl) accessingType;
-        final HotSpotResolvedObjectTypeImpl klass = compilerToVm.lookupType(name, hsAccessingType.mirror(), resolve);
+        try {
+            final HotSpotResolvedObjectTypeImpl klass = compilerToVm.lookupType(name, hsAccessingType.mirror(), resolve);
 
-        if (klass == null) {
-            assert resolve == false;
-            return HotSpotUnresolvedJavaType.create(this, name);
+            if (klass == null) {
+                assert resolve == false;
+                return HotSpotUnresolvedJavaType.create(this, name);
+            }
+            return klass;
+        } catch (ClassNotFoundException e) {
+            throw (NoClassDefFoundError) new NoClassDefFoundError().initCause(e);
         }
-        return klass;
     }
 
     public JVMCIBackend getHostJVMCIBackend() {
--- a/test/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java	Wed Aug 23 23:38:06 2017 +0200
@@ -79,8 +79,17 @@
     }
 
     public static HotSpotResolvedObjectType lookupType(String name,
+            Class<?> accessingClass, boolean resolve) throws ClassNotFoundException {
+        return CTVM.lookupType(name, accessingClass, resolve);
+    }
+
+    public static HotSpotResolvedObjectType lookupTypeHelper(String name,
             Class<?> accessingClass, boolean resolve) {
-        return CTVM.lookupType(name, accessingClass, resolve);
+        try {
+            return lookupType(name, accessingClass, resolve);
+        } catch (ClassNotFoundException e) {
+            throw (NoClassDefFoundError) new NoClassDefFoundError().initCause(e);
+        }
     }
 
     public static Object resolveConstantInPool(ConstantPool constantPool, int cpi) {
--- a/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java	Wed Aug 23 23:38:06 2017 +0200
@@ -107,7 +107,7 @@
         HotSpotResolvedJavaMethod testMethod = CTVMUtilities.getResolvedMethod(method);
 
         HotSpotResolvedObjectType resolvedType = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.receiver), getClass(),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.receiver), getClass(),
                 /* resolve = */ true);
         HotSpotResolvedJavaMethod concreteMethod = CompilerToVMHelper
                 .findUniqueConcreteMethod(resolvedType, testMethod);
--- a/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java	Wed Aug 23 23:38:06 2017 +0200
@@ -82,7 +82,7 @@
         System.out.println(tcase);
         String className = tcase.holder.getName();
         HotSpotResolvedObjectType resolvedClazz = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.holder),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.holder),
                         getClass(), /* resolve = */ true);
         HotSpotResolvedJavaMethod initializer = CompilerToVMHelper
                 .getClassInitializer(resolvedClazz);
--- a/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java	Wed Aug 23 23:38:06 2017 +0200
@@ -65,7 +65,7 @@
 
     public static void testClass(Class cls) {
         HotSpotResolvedObjectType type = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(cls),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(cls),
                         GetConstantPoolTest.class, /* resolve = */ true);
         test(type);
     }
--- a/test/compiler/jvmci/compilerToVM/GetImplementorTest.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/compilerToVM/GetImplementorTest.java	Wed Aug 23 23:38:06 2017 +0200
@@ -101,13 +101,13 @@
     private void runTest(TestCase tcase) {
         System.out.println(tcase);
         HotSpotResolvedObjectType resolvedIface = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.anInterface),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.anInterface),
                         getClass(), /* resolve = */ true);
         HotSpotResolvedObjectType resolvedImplementer = CompilerToVMHelper
                 .getImplementor(resolvedIface);
         HotSpotResolvedObjectType resolvedExpected = null;
         if (tcase.expectedImplementer != null) {
-            resolvedExpected = CompilerToVMHelper.lookupType(Utils
+            resolvedExpected = CompilerToVMHelper.lookupTypeHelper(Utils
                     .toJVMTypeSignature(tcase.expectedImplementer),
                     getClass(), /* resolve = */ true);
         }
--- a/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java	Wed Aug 23 23:38:06 2017 +0200
@@ -131,7 +131,7 @@
         System.out.println(tcase);
         Method method = tcase.holder.getDeclaredMethod(tcase.methodName);
         HotSpotResolvedObjectType metaspaceKlass = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.receiver),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.receiver),
                         getClass(), /* resolve = */ true);
         HotSpotResolvedJavaMethod metaspaceMethod = CTVMUtilities
                 .getResolvedMethod(tcase.holder, method);
--- a/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java	Wed Aug 23 23:38:06 2017 +0200
@@ -85,7 +85,7 @@
     private void runTest(TestCase tcase) {
         System.out.println(tcase);
         HotSpotResolvedObjectType metaspaceKlass = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.aClass),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.aClass),
                         getClass(), /* resolve = */ true);
         Asserts.assertEQ(tcase.expected,
                 CompilerToVMHelper.hasFinalizableSubclass(metaspaceKlass),
--- a/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java	Thu Aug 24 08:38:50 2017 +0000
+++ b/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java	Wed Aug 23 23:38:06 2017 +0200
@@ -134,13 +134,13 @@
                 .getResolvedMethod(tcase.holder,
                         tcase.holder.getDeclaredMethod(tcase.methodName));
         HotSpotResolvedObjectType holderMetaspace = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.holder),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.holder),
                         getClass(), /* resolve = */ true);
         HotSpotResolvedObjectType callerMetaspace = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.caller),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.caller),
                         getClass(), /* resolve = */ true);
         HotSpotResolvedObjectType receiverMetaspace = CompilerToVMHelper
-                .lookupType(Utils.toJVMTypeSignature(tcase.receiver),
+                .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.receiver),
                         getClass(), /* resolve = */ true);
 
         // Can only resolve methods on a linked class so force initialization