30 import java.lang.invoke.MethodHandleNatives.Constants; |
30 import java.lang.invoke.MethodHandleNatives.Constants; |
31 import java.lang.invoke.MethodHandles.Lookup; |
31 import java.lang.invoke.MethodHandles.Lookup; |
32 import static java.lang.invoke.MethodHandleStatics.*; |
32 import static java.lang.invoke.MethodHandleStatics.*; |
33 |
33 |
34 /** |
34 /** |
35 * A symbolic reference obtained by cracking a method handle into its consitutent symbolic parts. |
35 * A symbolic reference obtained by cracking a direct method handle |
|
36 * into its consitutent symbolic parts. |
36 * To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}. |
37 * To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}. |
37 * <p> |
38 * <h1><a name="directmh"></a>Direct Method Handles</h1> |
38 * A <em>direct method handle</em> represents a method, constructor, or field without |
39 * A <em>direct method handle</em> represents a method, constructor, or field without |
39 * any intervening argument bindings or other transformations. |
40 * any intervening argument bindings or other transformations. |
40 * The method, constructor, or field referred to by a direct method handle is called |
41 * The method, constructor, or field referred to by a direct method handle is called |
41 * its <em>underlying member</em>. |
42 * its <em>underlying member</em>. |
42 * Direct method handles may be obtained in any of these ways: |
43 * Direct method handles may be obtained in any of these ways: |
54 * to convert a {@link Constructor} into a method handle. |
55 * to convert a {@link Constructor} into a method handle. |
55 * <li>By calling the factory method {@link Lookup#unreflectGetter Lookup.unreflectGetter} |
56 * <li>By calling the factory method {@link Lookup#unreflectGetter Lookup.unreflectGetter} |
56 * or {@link Lookup#unreflectSetter Lookup.unreflectSetter} |
57 * or {@link Lookup#unreflectSetter Lookup.unreflectSetter} |
57 * to convert a {@link Field} into a method handle. |
58 * to convert a {@link Field} into a method handle. |
58 * </ul> |
59 * </ul> |
59 * In all of these cases, it is possible to crack the resulting direct method handle |
60 * |
|
61 * <h1>Restrictions on Cracking</h1> |
|
62 * Given a suitable {@code Lookup} object, it is possible to crack any direct method handle |
60 * to recover a symbolic reference for the underlying method, constructor, or field. |
63 * to recover a symbolic reference for the underlying method, constructor, or field. |
61 * Cracking must be done via a {@code Lookup} object equivalent to that which created |
64 * Cracking must be done via a {@code Lookup} object equivalent to that which created |
62 * the target method handle, or which has enough access permissions to recreate |
65 * the target method handle, or which has enough access permissions to recreate |
63 * an equivalent method handle. |
66 * an equivalent method handle. |
64 * <p> |
67 * <p> |
200 /** |
203 /** |
201 * Returns the access modifiers of the underlying member. |
204 * Returns the access modifiers of the underlying member. |
202 * @return the Java language modifiers for underlying member, |
205 * @return the Java language modifiers for underlying member, |
203 * or -1 if the member cannot be accessed |
206 * or -1 if the member cannot be accessed |
204 * @see Modifier |
207 * @see Modifier |
205 * @see reflectAs |
208 * @see #reflectAs |
206 */ |
209 */ |
207 public int getModifiers(); |
210 public int getModifiers(); |
208 |
211 |
209 /** |
212 /** |
210 * Determines if the underlying member was a variable arity method or constructor. |
213 * Determines if the underlying member was a variable arity method or constructor. |