GeezerVison is showing docs.oracle.com — MethodHandleInfo (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.lang.invoke
Interface MethodHandleInfo
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods
| Modifier and Type |
Method |
Description |
Class<?> |
getDeclaringClass() |
Returns the class in which the cracked method handle's underlying member was defined.
|
MethodType |
getMethodType() |
Returns the nominal type of the cracked symbolic reference, expressed as a method type.
|
int |
getModifiers() |
Returns the access modifiers of the underlying member.
|
String |
getName() |
Returns the name of the cracked method handle's underlying member.
|
int |
getReferenceKind() |
Returns the reference kind of the cracked method handle, which in turn
determines whether the method handle's underlying member was a constructor, method, or field.
|
default boolean |
isVarArgs() |
Determines if the underlying member was a variable arity method or constructor.
|
static String |
referenceKindToString(int referenceKind) |
Returns the descriptive name of the given reference kind,
as defined in the table above.
|
<T extends Member> T |
reflectAs(Class<T> expected,
MethodHandles.Lookup lookup) |
Reflects the underlying member as a method, constructor, or field object.
|
static String |
toString(int kind,
Class<?> defc,
String name,
MethodType type) |
Returns a string representation for a MethodHandleInfo,
given the four parts of its symbolic reference.
|
-
-
Method Detail
-
getReferenceKind
int getReferenceKind()
Returns the reference kind of the cracked method handle, which in turn
determines whether the method handle's underlying member was a constructor, method, or field.
See the table above for definitions.
- Returns:
- the integer code for the kind of reference used to access the underlying member
-
reflectAs
<T extends Member> T reflectAs(Class<T> expected,
MethodHandles.Lookup lookup)
Reflects the underlying member as a method, constructor, or field object.
If the underlying member is public, it is reflected as if by
getMethod, getConstructor, or getField.
Otherwise, it is reflected as if by
getDeclaredMethod, getDeclaredConstructor, or getDeclaredField.
The underlying member must be accessible to the given lookup object.
- Type Parameters:
T - the desired type of the result, either Member or a subtype
- Parameters:
expected - a class object representing the desired result type T
lookup - the lookup object that created this MethodHandleInfo, or one with equivalent access privileges
- Returns:
- a reference to the method, constructor, or field object
- Throws:
ClassCastException - if the member is not of the expected type
NullPointerException - if either argument is null
IllegalArgumentException - if the underlying member is not accessible to the given lookup object
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|