# HG changeset patch # User never # Date 1547529062 28800 # Mon Jan 14 21:11:02 2019 -0800 # Node ID ecba24de32642d99446fc1e610de7e9551835089 # Parent 8065db7231aece3da11258716280e088867c54c5 8215748: Application fails when executed with Graal diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -602,6 +602,16 @@ return NULL; } + if (method->name() == vmSymbols::clone_name() && + resolved == SystemDictionary::Object_klass() && + recv_klass->is_array_klass()) { + // Resolution of the clone method on arrays always returns Object.clone even though that method + // has protected access. There's some trickery in the access checking to make this all work out + // so it's necessary to pass in the array class as the resolved class to properly trigger this. + // Otherwise it's impossible to resolve the array clone methods through JVMCI. + resolved = recv_klass; + } + LinkInfo link_info(resolved, h_name, h_signature, caller_klass); methodHandle m; // Only do exact lookup if receiver klass has been linked. Otherwise, diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java @@ -168,6 +168,26 @@ } + static class ClassType { + } + + interface InterfaceType { + } + + @Test + public void testCloneAccessibility() { + /* + * The resolution machinery for clone on arrays has some hacks in that show up in odd places + * so make sure that resolveMethod works as expected. + */ + ResolvedJavaType interfaceType = getType(InterfaceType.class); + ResolvedJavaType classType = getType(ClassType.class); + ResolvedJavaType arrayType = getType(double[].class); + ResolvedJavaMethod cloneMethod = getMethod(getType(Object.class), "clone"); + assertEquals("Can't resolve clone for class", cloneMethod, arrayType.resolveMethod(cloneMethod, classType)); + assertEquals("Can't resolve clone for interface", cloneMethod, arrayType.resolveMethod(cloneMethod, interfaceType)); + } + static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) { for (ResolvedJavaMethod method : type.getDeclaredMethods()) { if (method.getName().equals(methodName)) {