8215748: Application fails when executed with Graal

Reviewed-by: iveresov, kvn, thartmann
This commit is contained in:
Tom Rodriguez 2019-01-15 22:59:33 -08:00
parent 1d014da14b
commit e590813950
2 changed files with 31 additions and 0 deletions
src/hotspot/share/jvmci
test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test

@ -602,6 +602,17 @@ C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_t
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. See
// LinkResolver::check_method_accessability for the matching logic.
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,

@ -168,6 +168,26 @@ public class ResolvedJavaTypeResolveMethodTest {
}
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)) {