src/share/classes/java/lang/invoke/MethodHandles.java

Print this page




  33 import sun.invoke.util.ValueConversions;
  34 import sun.invoke.util.VerifyAccess;
  35 import sun.invoke.util.Wrapper;
  36 import sun.reflect.CallerSensitive;
  37 import sun.reflect.Reflection;
  38 import sun.reflect.misc.ReflectUtil;
  39 import sun.security.util.SecurityConstants;
  40 import static java.lang.invoke.MethodHandleStatics.*;
  41 import static java.lang.invoke.MethodHandleNatives.Constants.*;
  42 import java.util.concurrent.ConcurrentHashMap;
  43 import sun.security.util.SecurityConstants;
  44 
  45 /**
  46  * This class consists exclusively of static methods that operate on or return
  47  * method handles. They fall into several categories:
  48  * <ul>
  49  * <li>Lookup methods which help create method handles for methods and fields.
  50  * <li>Combinator methods, which combine or transform pre-existing method handles into new ones.
  51  * <li>Other factory methods to create method handles that emulate other common JVM operations or control flow patterns.
  52  * </ul>
  53  * <p>
  54  * @author John Rose, JSR 292 EG
  55  * @since 1.7
  56  */
  57 public class MethodHandles {
  58 
  59     private MethodHandles() { }  // do not instantiate
  60 
  61     private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory();
  62     static { MethodHandleImpl.initStatics(); }
  63     // See IMPL_LOOKUP below.
  64 
  65     //// Method handle creation from ordinary methods.
  66 
  67     /**
  68      * Returns a {@link Lookup lookup object} with
  69      * full capabilities to emulate all supported bytecode behaviors of the caller.
  70      * These capabilities include <a href="MethodHandles.Lookup.html#privacc">private access</a> to the caller.
  71      * Factory methods on the lookup object can create
  72      * <a href="MethodHandleInfo.html#directmh">direct method handles</a>
  73      * for any member that the caller has access to via bytecodes,




  33 import sun.invoke.util.ValueConversions;
  34 import sun.invoke.util.VerifyAccess;
  35 import sun.invoke.util.Wrapper;
  36 import sun.reflect.CallerSensitive;
  37 import sun.reflect.Reflection;
  38 import sun.reflect.misc.ReflectUtil;
  39 import sun.security.util.SecurityConstants;
  40 import static java.lang.invoke.MethodHandleStatics.*;
  41 import static java.lang.invoke.MethodHandleNatives.Constants.*;
  42 import java.util.concurrent.ConcurrentHashMap;
  43 import sun.security.util.SecurityConstants;
  44 
  45 /**
  46  * This class consists exclusively of static methods that operate on or return
  47  * method handles. They fall into several categories:
  48  * <ul>
  49  * <li>Lookup methods which help create method handles for methods and fields.
  50  * <li>Combinator methods, which combine or transform pre-existing method handles into new ones.
  51  * <li>Other factory methods to create method handles that emulate other common JVM operations or control flow patterns.
  52  * </ul>
  53  *
  54  * @author John Rose, JSR 292 EG
  55  * @since 1.7
  56  */
  57 public class MethodHandles {
  58 
  59     private MethodHandles() { }  // do not instantiate
  60 
  61     private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory();
  62     static { MethodHandleImpl.initStatics(); }
  63     // See IMPL_LOOKUP below.
  64 
  65     //// Method handle creation from ordinary methods.
  66 
  67     /**
  68      * Returns a {@link Lookup lookup object} with
  69      * full capabilities to emulate all supported bytecode behaviors of the caller.
  70      * These capabilities include <a href="MethodHandles.Lookup.html#privacc">private access</a> to the caller.
  71      * Factory methods on the lookup object can create
  72      * <a href="MethodHandleInfo.html#directmh">direct method handles</a>
  73      * for any member that the caller has access to via bytecodes,