src/java.base/share/classes/java/lang/constant/MethodTypeDescImpl.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54965 e022b9cb35a5
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    24  */
    24  */
    25 package java.lang.constant;
    25 package java.lang.constant;
    26 
    26 
    27 import java.lang.invoke.MethodHandles;
    27 import java.lang.invoke.MethodHandles;
    28 import java.lang.invoke.MethodType;
    28 import java.lang.invoke.MethodType;
       
    29 import java.security.AccessController;
       
    30 import java.security.PrivilegedAction;
    29 import java.util.Arrays;
    31 import java.util.Arrays;
    30 import java.util.List;
    32 import java.util.List;
    31 
    33 
    32 import static java.util.Objects.requireNonNull;
    34 import static java.util.Objects.requireNonNull;
    33 
    35 
   129         System.arraycopy(argTypes, pos, newArgs, pos+paramTypes.length, argTypes.length - pos);
   131         System.arraycopy(argTypes, pos, newArgs, pos+paramTypes.length, argTypes.length - pos);
   130         return MethodTypeDesc.of(returnType, newArgs);
   132         return MethodTypeDesc.of(returnType, newArgs);
   131     }
   133     }
   132 
   134 
   133     @Override
   135     @Override
   134     public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) {
   136     public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException {
   135         return MethodType.fromMethodDescriptorString(descriptorString(), lookup.lookupClass().getClassLoader());
   137         MethodType mtype = AccessController.doPrivileged(new PrivilegedAction<>() {
       
   138             @Override
       
   139             public MethodType run() {
       
   140                 return MethodType.fromMethodDescriptorString(descriptorString(),
       
   141                                                              lookup.lookupClass().getClassLoader());
       
   142             }
       
   143         });
       
   144 
       
   145         // let's check that the lookup has access to all the types in the method type
       
   146         lookup.accessClass(mtype.returnType());
       
   147         for (Class<?> paramType: mtype.parameterArray()) {
       
   148             lookup.accessClass(paramType);
       
   149         }
       
   150         return mtype;
   136     }
   151     }
   137 
   152 
   138     /**
   153     /**
   139      * Returns {@code true} if this {@linkplain MethodTypeDescImpl} is
   154      * Returns {@code true} if this {@linkplain MethodTypeDescImpl} is
   140      * equal to another {@linkplain MethodTypeDescImpl}.  Equality is
   155      * equal to another {@linkplain MethodTypeDescImpl}.  Equality is