8226709: MethodTypeDesc::resolveConstantDesc needs access check per the specification

Reviewed-by: mchung, mcimadamore
This commit is contained in:
Vicente Romero 2019-06-25 18:21:21 -04:00
parent 5c5126f5ee
commit b2e7d0367e
4 changed files with 148 additions and 2 deletions

View file

@ -131,8 +131,14 @@ final class MethodTypeDescImpl implements MethodTypeDesc {
}
@Override
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) {
return MethodType.fromMethodDescriptorString(descriptorString(), lookup.lookupClass().getClassLoader());
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException {
MethodType mtype = MethodType.fromMethodDescriptorString(descriptorString(), lookup.lookupClass().getClassLoader());
// let's check that the lookup has access to all the types in the method type
lookup.accessClass(mtype.returnType());
for (Class<?> paramType: mtype.parameterArray()) {
lookup.accessClass(paramType);
}
return mtype;
}
/**