mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8304929: MethodTypeDesc throws an unchecked exception than ReflectiveOperationException when a component class cannot be resolved
Reviewed-by: jvernee
This commit is contained in:
parent
d63d6e23d1
commit
96e4a1876a
2 changed files with 25 additions and 10 deletions
|
@ -213,16 +213,25 @@ public final class MethodTypeDescImpl implements MethodTypeDesc {
|
|||
|
||||
@Override
|
||||
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException {
|
||||
@SuppressWarnings("removal")
|
||||
MethodType mtype = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public MethodType run() {
|
||||
return MethodType.fromMethodDescriptorString(descriptorString(),
|
||||
lookup.lookupClass().getClassLoader());
|
||||
}
|
||||
});
|
||||
MethodType mtype;
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
MethodType mt = AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public MethodType run() {
|
||||
return MethodType.fromMethodDescriptorString(descriptorString(),
|
||||
lookup.lookupClass().getClassLoader());
|
||||
}
|
||||
});
|
||||
mtype = mt;
|
||||
} catch (TypeNotPresentException ex) {
|
||||
throw (ClassNotFoundException) ex.getCause();
|
||||
}
|
||||
|
||||
// let's check that the lookup has access to all the types in the method type
|
||||
// Some method types, like ones containing a package private class not accessible
|
||||
// to the overriding method, can be valid method descriptors and obtained from
|
||||
// MethodType.fromMethodDescriptor, but ldc instruction will fail to resolve such
|
||||
// MethodType constants due to access control (JVMS 5.4.3.1 and 5.4.3.5)
|
||||
lookup.accessClass(mtype.returnType());
|
||||
for (Class<?> paramType: mtype.parameterArray()) {
|
||||
lookup.accessClass(paramType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue