Package net.bytebuddy.dynamic.loading
Class ClassInjector.UsingLookup
- java.lang.Object
-
- net.bytebuddy.dynamic.loading.ClassInjector.AbstractBase
-
- net.bytebuddy.dynamic.loading.ClassInjector.UsingLookup
-
- All Implemented Interfaces:
ClassInjector
- Enclosing interface:
- ClassInjector
@Enhance public static class ClassInjector.UsingLookup extends ClassInjector.AbstractBase
A class injector that uses a
java.lang.invoke.MethodHandles$Lookupobject for defining a class.Important: This functionality is only available starting from Java 9.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceClassInjector.UsingLookup.DispatcherA dispatcher for interacting with a method handle lookup.-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe
-
-
Field Summary
-
Fields inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ALLOW_EXISTING_TYPES, SUPPRESS_ACCESS_CHECKS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedUsingLookup(Object lookup)Creates a new class injector using a lookup instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassInjector.UsingLookupin(Class<?> type)Resolves this injector to use the supplied type's scope.Map<String,Class<?>>injectRaw(Map<? extends String,byte[]> types)Injects the given types into the represented class loader using a mapping from name to binary representation.booleanisAlive()Indicates if this class injector is available on the current VM.static booleanisAvailable()Checks if the current VM is capable of defining classes using a method handle lookup.Class<?>lookupType()Returns the lookup type this injector is based upon.static ClassInjector.UsingLookupof(Object lookup)Creates class injector that defines a class using a method handle lookup.-
Methods inherited from class net.bytebuddy.dynamic.loading.ClassInjector.AbstractBase
inject
-
-
-
-
Constructor Detail
-
UsingLookup
protected UsingLookup(Object lookup)
Creates a new class injector using a lookup instance.- Parameters:
lookup- Thejava.lang.invoke.MethodHandles$Lookupinstance to use.
-
-
Method Detail
-
of
public static ClassInjector.UsingLookup of(Object lookup)
Creates class injector that defines a class using a method handle lookup.- Parameters:
lookup- Thejava.lang.invoke.MethodHandles$Lookupinstance to use.- Returns:
- An appropriate class injector.
-
lookupType
public Class<?> lookupType()
Returns the lookup type this injector is based upon.- Returns:
- The lookup type.
-
in
public ClassInjector.UsingLookup in(Class<?> type)
Resolves this injector to use the supplied type's scope.- Parameters:
type- The type to resolve the access scope for.- Returns:
- An new injector with the specified scope.
-
isAlive
public boolean isAlive()
Indicates if this class injector is available on the current VM.- Returns:
trueif this injector is available on the current VM.
-
injectRaw
public Map<String,Class<?>> injectRaw(Map<? extends String,byte[]> types)
Injects the given types into the represented class loader using a mapping from name to binary representation.- Parameters:
types- The types to load via injection.- Returns:
- The loaded types that were passed as arguments.
-
isAvailable
public static boolean isAvailable()
Checks if the current VM is capable of defining classes using a method handle lookup.- Returns:
trueif the current VM is capable of defining classes using a lookup.
-
-