Package io.microsphere.invoke
Class MethodHandleUtils
- java.lang.Object
-
- io.microsphere.invoke.MethodHandleUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MethodHandleUtils.LookupMode
The allowedMethodHandles.Lookup
modes enumeration
-
Field Summary
Fields Modifier and Type Field Description static int
ALL_MODES
A single-bit mask representing all accesses (public, private, protected and package) The value, 0x0f, happens to be the same as the value of the modifier bit.static int
MODULE
A single-bit mask representingmodule
access, which may contribute to the result oflookupModes
.static int
ORIGINAL
A single-bit mask representingoriginal
access which may contribute to the result oflookupModes
.static java.lang.invoke.MethodHandles.Lookup
PUBLIC_LOOKUP
TheMethodHandles.Lookup
forMethodHandles.publicLookup()
static int
UNCONDITIONAL
A single-bit mask representingunconditional
access which may contribute to the result oflookupModes
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.invoke.MethodHandle
find(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class[] parameterTypes, ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,java.lang.invoke.MethodType,java.lang.invoke.MethodHandle> function)
static java.lang.invoke.MethodHandle
findStatic(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class... parameterTypes)
The convenient method to findMethodHandles.Lookup.findStatic(Class, String, MethodType)
static java.lang.invoke.MethodHandle
findVirtual(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class... parameterTypes)
The convenient method to findMethodHandles.Lookup.findVirtual(Class, String, MethodType)
static java.lang.invoke.MethodHandles.Lookup
lookup(java.lang.Class<?> requestedClass)
Create an instance ofMethodHandles.Lookup
by the specified lookup class withall accesses (public, private, protected and package)
static java.lang.invoke.MethodHandles.Lookup
lookup(java.lang.Class<?> requestedClass, MethodHandleUtils.LookupMode... lookupModes)
Create an instance ofMethodHandles.Lookup
by the specified lookup class withall access (public, private, protected and package)
-
-
-
Field Detail
-
MODULE
public static final int MODULE
A single-bit mask representingmodule
access, which may contribute to the result oflookupModes
. The value is0x10
, which does not correspond meaningfully to any particular modifier bit. In conjunction with thePUBLIC
modifier bit, aLookup
with this lookup mode can access all public types in the module of the lookup class and public types in packages exported by other modules to the module of the class to be looked up.If this lookup mode is set, the previous lookup class is always
null
.- Since:
- 9
- See Also:
MethodHandles.Lookup#MODULE
, Constant Field Values
-
UNCONDITIONAL
public static final int UNCONDITIONAL
A single-bit mask representingunconditional
access which may contribute to the result oflookupModes
. The value is0x20
, which does not correspond meaningfully to any particular modifier bit. ALookup
with this lookup mode assumes readability. This lookup mode can access all public members of public types of all modules when the type is in a package that isexported unconditionally
.If this lookup mode is set, the previous lookup class is always
null
.- Since:
- 9
- See Also:
MethodHandles.publicLookup()
,MethodHandles.Lookup#UNCONDITIONAL
, Constant Field Values
-
ORIGINAL
public static final int ORIGINAL
A single-bit mask representingoriginal
access which may contribute to the result oflookupModes
. The value is0x40
, which does not correspond meaningfully to any particular modifier bit.If this lookup mode is set, the
Lookup
object must be created by the original lookup class by callingMethodHandles.lookup()
method or by a bootstrap method invoked by the VM. TheLookup
object with this lookup mode has full privilege access.- Since:
- 16
- See Also:
MethodHandles.Lookup#ORIGINAL
, Constant Field Values
-
ALL_MODES
public static final int ALL_MODES
A single-bit mask representing all accesses (public, private, protected and package) The value, 0x0f, happens to be the same as the value of the modifier bit.- See Also:
- Constant Field Values
-
PUBLIC_LOOKUP
public static final java.lang.invoke.MethodHandles.Lookup PUBLIC_LOOKUP
TheMethodHandles.Lookup
forMethodHandles.publicLookup()
-
-
Method Detail
-
lookup
public static java.lang.invoke.MethodHandles.Lookup lookup(java.lang.Class<?> requestedClass)
Create an instance ofMethodHandles.Lookup
by the specified lookup class withall accesses (public, private, protected and package)
- Parameters:
requestedClass
- the class to be looked up- Returns:
- non-null
-
lookup
public static java.lang.invoke.MethodHandles.Lookup lookup(java.lang.Class<?> requestedClass, MethodHandleUtils.LookupMode... lookupModes)
Create an instance ofMethodHandles.Lookup
by the specified lookup class withall access (public, private, protected and package)
- Parameters:
requestedClass
- the class to be looked up- Returns:
- non-null
-
findVirtual
public static java.lang.invoke.MethodHandle findVirtual(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class... parameterTypes)
The convenient method to findMethodHandles.Lookup.findVirtual(Class, String, MethodType)
- Parameters:
requestedClass
- the class to be looked upmethodName
- the target method nameparameterTypes
- the types of target method parameters- Returns:
MethodHandle
-
findStatic
public static java.lang.invoke.MethodHandle findStatic(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class... parameterTypes)
The convenient method to findMethodHandles.Lookup.findStatic(Class, String, MethodType)
- Parameters:
requestedClass
- the class to be looked upmethodName
- the target method nameparameterTypes
- the types of target method parameters- Returns:
MethodHandle
-
find
protected static java.lang.invoke.MethodHandle find(java.lang.Class<?> requestedClass, java.lang.String methodName, java.lang.Class[] parameterTypes, ThrowableBiFunction<java.lang.invoke.MethodHandles.Lookup,java.lang.invoke.MethodType,java.lang.invoke.MethodHandle> function)
-
-