nashorn/src/jdk/internal/dynalink/support/Lookup.java
changeset 18841 9bbc4b8832b2
parent 16245 6a1c6c8bc113
child 19455 b972b61a6921
equal deleted inserted replaced
18840:3e7bff1b7b59 18841:9bbc4b8832b2
   120      *
   120      *
   121      * @param m the method to unreflect
   121      * @param m the method to unreflect
   122      * @return the unreflected method handle.
   122      * @return the unreflected method handle.
   123      */
   123      */
   124     public MethodHandle unreflect(Method m) {
   124     public MethodHandle unreflect(Method m) {
       
   125         return unreflect(lookup, m);
       
   126     }
       
   127 
       
   128     /**
       
   129      * Performs a {@link java.lang.invoke.MethodHandles.Lookup#unreflect(Method)}, converting any encountered
       
   130      * {@link IllegalAccessException} into an {@link IllegalAccessError}.
       
   131      *
       
   132      * @param lookup the lookup used to unreflect
       
   133      * @param m the method to unreflect
       
   134      * @return the unreflected method handle.
       
   135      */
       
   136     public static MethodHandle unreflect(MethodHandles.Lookup lookup, Method m) {
   125         try {
   137         try {
   126             return lookup.unreflect(m);
   138             return lookup.unreflect(m);
   127         } catch(IllegalAccessException e) {
   139         } catch(IllegalAccessException e) {
   128             final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect method " + m);
   140             final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect method " + m);
   129             ee.initCause(e);
   141             ee.initCause(e);
   130             throw ee;
   142             throw ee;
   131         }
   143         }
   132     }
   144     }
   133 
       
   134 
   145 
   135     /**
   146     /**
   136      * Performs a {@link java.lang.invoke.MethodHandles.Lookup#unreflectGetter(Field)}, converting any encountered
   147      * Performs a {@link java.lang.invoke.MethodHandles.Lookup#unreflectGetter(Field)}, converting any encountered
   137      * {@link IllegalAccessException} into an {@link IllegalAccessError}.
   148      * {@link IllegalAccessException} into an {@link IllegalAccessError}.
   138      *
   149      *
   200      *
   211      *
   201      * @param c the constructor to unreflect
   212      * @param c the constructor to unreflect
   202      * @return the unreflected constructor handle.
   213      * @return the unreflected constructor handle.
   203      */
   214      */
   204     public MethodHandle unreflectConstructor(Constructor<?> c) {
   215     public MethodHandle unreflectConstructor(Constructor<?> c) {
       
   216         return unreflectConstructor(lookup, c);
       
   217     }
       
   218 
       
   219     /**
       
   220      * Performs a {@link java.lang.invoke.MethodHandles.Lookup#unreflectConstructor(Constructor)}, converting any
       
   221      * encountered {@link IllegalAccessException} into an {@link IllegalAccessError}.
       
   222      *
       
   223      * @param lookup the lookup used to unreflect
       
   224      * @param c the constructor to unreflect
       
   225      * @return the unreflected constructor handle.
       
   226      */
       
   227     public static MethodHandle unreflectConstructor(MethodHandles.Lookup lookup, Constructor<?> c) {
   205         try {
   228         try {
   206             return lookup.unreflectConstructor(c);
   229             return lookup.unreflectConstructor(c);
   207         } catch(IllegalAccessException e) {
   230         } catch(IllegalAccessException e) {
   208             final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect constructor " + c);
   231             final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect constructor " + c);
   209             ee.initCause(e);
   232             ee.initCause(e);