public class Lookup extends Object
Modifier and Type | Field and Description |
---|---|
static Lookup |
PUBLIC
A canonical Lookup object that wraps
MethodHandles.publicLookup() . |
Constructor and Description |
---|
Lookup(MethodHandles.Lookup lookup)
Creates a new instance, bound to an instance of
MethodHandles.Lookup . |
public static final Lookup PUBLIC
MethodHandles.publicLookup()
.public Lookup(MethodHandles.Lookup lookup)
MethodHandles.Lookup
.lookup
- the MethodHandles.Lookup
it delegates to.public MethodHandle unreflect(Method m)
MethodHandles.Lookup.unreflect(Method)
, converting any encountered
IllegalAccessException
into an IllegalAccessError
.m
- the method to unreflectpublic static MethodHandle unreflect(MethodHandles.Lookup lookup, Method m)
MethodHandles.Lookup.unreflect(Method)
, converting any encountered
IllegalAccessException
into an IllegalAccessError
.lookup
- the lookup used to unreflectm
- the method to unreflectpublic MethodHandle unreflectGetter(Field f)
MethodHandles.Lookup.unreflectGetter(Field)
, converting any encountered
IllegalAccessException
into an IllegalAccessError
.f
- the field for which a getter is unreflectedpublic MethodHandle findGetter(Class<?> refc, String name, Class<?> type)
MethodHandles.Lookup.findGetter(Class, String, Class)
, converting any
encountered IllegalAccessException
into an IllegalAccessError
and NoSuchFieldException
into a NoSuchFieldError
.refc
- the class declaring the fieldname
- the name of the fieldtype
- the type of the fieldIllegalAccessError
- if the field is inaccessible.NoSuchFieldError
- if the field does not exist.public MethodHandle unreflectSetter(Field f)
MethodHandles.Lookup.unreflectSetter(Field)
, converting any encountered
IllegalAccessException
into an IllegalAccessError
.f
- the field for which a setter is unreflectedpublic MethodHandle unreflectConstructor(Constructor<?> c)
MethodHandles.Lookup.unreflectConstructor(Constructor)
, converting any
encountered IllegalAccessException
into an IllegalAccessError
.c
- the constructor to unreflectpublic static MethodHandle unreflectConstructor(MethodHandles.Lookup lookup, Constructor<?> c)
MethodHandles.Lookup.unreflectConstructor(Constructor)
, converting any
encountered IllegalAccessException
into an IllegalAccessError
.lookup
- the lookup used to unreflectc
- the constructor to unreflectpublic MethodHandle findSpecial(Class<?> declaringClass, String name, MethodType type)
IllegalAccessException
into an
IllegalAccessError
and a NoSuchMethodException
into a NoSuchMethodError
.declaringClass
- class declaring the methodname
- the name of the methodtype
- the type of the methodIllegalAccessError
- if the method is inaccessible.NoSuchMethodError
- if the method does not exist.public MethodHandle findStatic(Class<?> declaringClass, String name, MethodType type)
IllegalAccessException
into an
IllegalAccessError
and a NoSuchMethodException
into a NoSuchMethodError
.declaringClass
- class declaring the methodname
- the name of the methodtype
- the type of the methodIllegalAccessError
- if the method is inaccessible.NoSuchMethodError
- if the method does not exist.public MethodHandle findVirtual(Class<?> declaringClass, String name, MethodType type)
IllegalAccessException
into an
IllegalAccessError
and a NoSuchMethodException
into a NoSuchMethodError
.declaringClass
- class declaring the methodname
- the name of the methodtype
- the type of the methodIllegalAccessError
- if the method is inaccessible.NoSuchMethodError
- if the method does not exist.public static MethodHandle findOwnSpecial(MethodHandles.Lookup lookup, String name, Class<?> rtype, Class<?>... ptypes)
findSpecial(Class, String, MethodType)
a method on that lookup's class.
Useful in classes' code for convenient linking to their own privates.lookup
- the lookup for the classname
- the name of the methodrtype
- the return type of the methodptypes
- the parameter types of the methodpublic MethodHandle findOwnSpecial(String name, Class<?> rtype, Class<?>... ptypes)
findSpecial(Class, String, MethodType)
a method on that lookup's class. Useful in classes'
code for convenient linking to their own privates. It's easier to use than findSpecial
in that you can
just list the parameter types, and don't have to specify lookup class.name
- the name of the methodrtype
- the return type of the methodptypes
- the parameter types of the methodpublic static MethodHandle findOwnStatic(MethodHandles.Lookup lookup, String name, Class<?> rtype, Class<?>... ptypes)
findStatic(Class, String, MethodType)
a method on that lookup's class.
Useful in classes' code for convenient linking to their own privates. It's easier to use than findStatic
in that you can just list the parameter types, and don't have to specify lookup class.lookup
- the lookup for the classname
- the name of the methodrtype
- the return type of the methodptypes
- the parameter types of the methodpublic MethodHandle findOwnStatic(String name, Class<?> rtype, Class<?>... ptypes)
findStatic(Class, String, MethodType)
a method on that lookup's class. Useful in classes'
code for convenient linking to their own privates. It's easier to use than findStatic
in that you can
just list the parameter types, and don't have to specify lookup class.name
- the name of the methodrtype
- the return type of the methodptypes
- the parameter types of the methodCopyright © 2015 Attila Szegedi. All rights reserved.