< prev index next >

src/java.base/share/classes/java/lang/invoke/MethodHandleInfo.java

Print this page




  26 package java.lang.invoke;
  27 
  28 import java.lang.reflect.*;
  29 import java.util.*;
  30 import java.lang.invoke.MethodHandleNatives.Constants;
  31 import java.lang.invoke.MethodHandles.Lookup;
  32 import static java.lang.invoke.MethodHandleStatics.*;
  33 
  34 /**
  35  * A symbolic reference obtained by cracking a direct method handle
  36  * into its consitutent symbolic parts.
  37  * To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}.
  38  * <h2><a id="directmh"></a>Direct Method Handles</h2>
  39  * A <em>direct method handle</em> represents a method, constructor, or field without
  40  * any intervening argument bindings or other transformations.
  41  * The method, constructor, or field referred to by a direct method handle is called
  42  * its <em>underlying member</em>.
  43  * Direct method handles may be obtained in any of these ways:
  44  * <ul>
  45  * <li>By executing an {@code ldc} instruction on a {@code CONSTANT_MethodHandle} constant.
  46  *     (See the Java Virtual Machine Specification, sections 4.4.8 and 5.4.3.)
  47  * <li>By calling one of the <a href="MethodHandles.Lookup.html#lookups">Lookup Factory Methods</a>,
  48  *     such as {@link Lookup#findVirtual Lookup.findVirtual},
  49  *     to resolve a symbolic reference into a method handle.
  50  *     A symbolic reference consists of a class, name string, and type.
  51  * <li>By calling the factory method {@link Lookup#unreflect Lookup.unreflect}
  52  *     or {@link Lookup#unreflectSpecial Lookup.unreflectSpecial}
  53  *     to convert a {@link Method} into a method handle.
  54  * <li>By calling the factory method {@link Lookup#unreflectConstructor Lookup.unreflectConstructor}
  55  *     to convert a {@link Constructor} into a method handle.
  56  * <li>By calling the factory method {@link Lookup#unreflectGetter Lookup.unreflectGetter}
  57  *     or {@link Lookup#unreflectSetter Lookup.unreflectSetter}
  58  *     to convert a {@link Field} into a method handle.
  59  * </ul>
  60  *
  61  * <h2>Restrictions on Cracking</h2>
  62  * Given a suitable {@code Lookup} object, it is possible to crack any direct method handle
  63  * to recover a symbolic reference for the underlying method, constructor, or field.
  64  * Cracking must be done via a {@code Lookup} object equivalent to that which created
  65  * the target method handle, or which has enough access permissions to recreate
  66  * an equivalent method handle.




  26 package java.lang.invoke;
  27 
  28 import java.lang.reflect.*;
  29 import java.util.*;
  30 import java.lang.invoke.MethodHandleNatives.Constants;
  31 import java.lang.invoke.MethodHandles.Lookup;
  32 import static java.lang.invoke.MethodHandleStatics.*;
  33 
  34 /**
  35  * A symbolic reference obtained by cracking a direct method handle
  36  * into its consitutent symbolic parts.
  37  * To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}.
  38  * <h2><a id="directmh"></a>Direct Method Handles</h2>
  39  * A <em>direct method handle</em> represents a method, constructor, or field without
  40  * any intervening argument bindings or other transformations.
  41  * The method, constructor, or field referred to by a direct method handle is called
  42  * its <em>underlying member</em>.
  43  * Direct method handles may be obtained in any of these ways:
  44  * <ul>
  45  * <li>By executing an {@code ldc} instruction on a {@code CONSTANT_MethodHandle} constant.
  46  *     (See the Java Virtual Machine Specification, sections {@jvms 4.4.8} and {@jvms 5.4.3}.)
  47  * <li>By calling one of the <a href="MethodHandles.Lookup.html#lookups">Lookup Factory Methods</a>,
  48  *     such as {@link Lookup#findVirtual Lookup.findVirtual},
  49  *     to resolve a symbolic reference into a method handle.
  50  *     A symbolic reference consists of a class, name string, and type.
  51  * <li>By calling the factory method {@link Lookup#unreflect Lookup.unreflect}
  52  *     or {@link Lookup#unreflectSpecial Lookup.unreflectSpecial}
  53  *     to convert a {@link Method} into a method handle.
  54  * <li>By calling the factory method {@link Lookup#unreflectConstructor Lookup.unreflectConstructor}
  55  *     to convert a {@link Constructor} into a method handle.
  56  * <li>By calling the factory method {@link Lookup#unreflectGetter Lookup.unreflectGetter}
  57  *     or {@link Lookup#unreflectSetter Lookup.unreflectSetter}
  58  *     to convert a {@link Field} into a method handle.
  59  * </ul>
  60  *
  61  * <h2>Restrictions on Cracking</h2>
  62  * Given a suitable {@code Lookup} object, it is possible to crack any direct method handle
  63  * to recover a symbolic reference for the underlying method, constructor, or field.
  64  * Cracking must be done via a {@code Lookup} object equivalent to that which created
  65  * the target method handle, or which has enough access permissions to recreate
  66  * an equivalent method handle.


< prev index next >