7077803: java.lang.InternalError in java.lang.invoke.MethodHandleNatives.init
Use correct access token for unreflecting MHs where setAccessible(true) Reviewed-by: never, twisti
This commit is contained in:
parent
ef856f2fe0
commit
1c49ad8a03
@ -948,10 +948,11 @@ return mh1;
|
|||||||
public MethodHandle unreflect(Method m) throws IllegalAccessException {
|
public MethodHandle unreflect(Method m) throws IllegalAccessException {
|
||||||
MemberName method = new MemberName(m);
|
MemberName method = new MemberName(m);
|
||||||
assert(method.isMethod());
|
assert(method.isMethod());
|
||||||
if (!m.isAccessible()) checkMethod(method.getDeclaringClass(), method, method.isStatic());
|
if (m.isAccessible())
|
||||||
|
return MethodHandleImpl.findMethod(method, true, /*no lookupClass*/ null);
|
||||||
|
checkMethod(method.getDeclaringClass(), method, method.isStatic());
|
||||||
MethodHandle mh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull());
|
MethodHandle mh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull());
|
||||||
if (!m.isAccessible()) mh = restrictProtectedReceiver(method, mh);
|
return restrictProtectedReceiver(method, mh);
|
||||||
return mh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1010,8 +1011,13 @@ return mh1;
|
|||||||
public MethodHandle unreflectConstructor(Constructor c) throws IllegalAccessException {
|
public MethodHandle unreflectConstructor(Constructor c) throws IllegalAccessException {
|
||||||
MemberName ctor = new MemberName(c);
|
MemberName ctor = new MemberName(c);
|
||||||
assert(ctor.isConstructor());
|
assert(ctor.isConstructor());
|
||||||
if (!c.isAccessible()) checkAccess(c.getDeclaringClass(), ctor);
|
MethodHandle rawCtor;
|
||||||
MethodHandle rawCtor = MethodHandleImpl.findMethod(ctor, false, lookupClassOrNull());
|
if (c.isAccessible()) {
|
||||||
|
rawCtor = MethodHandleImpl.findMethod(ctor, false, /*no lookupClass*/ null);
|
||||||
|
} else {
|
||||||
|
checkAccess(c.getDeclaringClass(), ctor);
|
||||||
|
rawCtor = MethodHandleImpl.findMethod(ctor, false, lookupClassOrNull());
|
||||||
|
}
|
||||||
MethodHandle allocator = MethodHandleImpl.makeAllocator(rawCtor);
|
MethodHandle allocator = MethodHandleImpl.makeAllocator(rawCtor);
|
||||||
return fixVarargs(allocator, rawCtor);
|
return fixVarargs(allocator, rawCtor);
|
||||||
}
|
}
|
||||||
@ -1226,7 +1232,7 @@ return mh1;
|
|||||||
? "expected a static field"
|
? "expected a static field"
|
||||||
: "expected a non-static field", this);
|
: "expected a non-static field", this);
|
||||||
if (trusted)
|
if (trusted)
|
||||||
return MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull());
|
return MethodHandleImpl.accessField(field, isSetter, /*no lookupClass*/ null);
|
||||||
checkAccess(refc, field);
|
checkAccess(refc, field);
|
||||||
MethodHandle mh = MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull());
|
MethodHandle mh = MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull());
|
||||||
return restrictProtectedReceiver(field, mh);
|
return restrictProtectedReceiver(field, mh);
|
||||||
|
Loading…
Reference in New Issue
Block a user