@HashCodeAndEqualsPlugin.Enhance public static class ClassInjector.UsingLookup extends ClassInjector.AbstractBase
A class injector that uses a java.lang.invoke.MethodHandles$Lookup
object for defining a class.
Important: This functionality is only available starting from Java 9.
Modifier and Type | Class and Description |
---|---|
protected static interface |
ClassInjector.UsingLookup.Dispatcher
A dispatcher for interacting with a method handle lookup.
|
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe
Modifier and Type | Field and Description |
---|---|
private static ClassInjector.UsingLookup.Dispatcher |
DISPATCHER
The dispatcher to interacting with method handles.
|
private java.lang.Object |
lookup
The
java.lang.invoke.MethodHandles$Lookup to use. |
private static int |
PACKAGE_LOOKUP
Indicates a lookup instance's package lookup mode.
|
ALLOW_EXISTING_TYPES, SUPPRESS_ACCESS_CHECKS
Modifier | Constructor and Description |
---|---|
protected |
UsingLookup(java.lang.Object lookup)
Creates a new class injector using a lookup instance.
|
Modifier and Type | Method and Description |
---|---|
ClassInjector.UsingLookup |
in(java.lang.Class<?> type)
Resolves this injector to use the supplied type's scope.
|
java.util.Map<java.lang.String,java.lang.Class<?>> |
injectRaw(java.util.Map<? extends java.lang.String,byte[]> types)
Injects the given types into the represented class loader using a mapping from name to binary representation.
|
boolean |
isAlive()
Indicates if this class injector is available on the current VM.
|
static boolean |
isAvailable()
Checks if the current VM is capable of defining classes using a method handle lookup.
|
java.lang.Class<?> |
lookupType()
Returns the lookup type this injector is based upon.
|
static ClassInjector.UsingLookup |
of(java.lang.Object lookup)
Creates class injector that defines a class using a method handle lookup.
|
inject
private static final ClassInjector.UsingLookup.Dispatcher DISPATCHER
private static final int PACKAGE_LOOKUP
private final java.lang.Object lookup
java.lang.invoke.MethodHandles$Lookup
to use.protected UsingLookup(java.lang.Object lookup)
lookup
- The java.lang.invoke.MethodHandles$Lookup
instance to use.public static ClassInjector.UsingLookup of(java.lang.Object lookup)
lookup
- The java.lang.invoke.MethodHandles$Lookup
instance to use.public java.lang.Class<?> lookupType()
public ClassInjector.UsingLookup in(java.lang.Class<?> type)
type
- The type to resolve the access scope for.public boolean isAlive()
true
if this injector is available on the current VM.public java.util.Map<java.lang.String,java.lang.Class<?>> injectRaw(java.util.Map<? extends java.lang.String,byte[]> types)
types
- The types to load via injection.public static boolean isAvailable()
true
if the current VM is capable of defining classes using a lookup.