Package net.bytebuddy.dynamic.loading
Class ClassInjector.UsingLookup
- java.lang.Object
-
- net.bytebuddy.dynamic.loading.ClassInjector.UsingLookup
-
- All Implemented Interfaces:
ClassInjector
- Enclosing interface:
- ClassInjector
public static class ClassInjector.UsingLookup extends java.lang.Object implements ClassInjector
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
ClassInjector.UsingLookup.Dispatcher
A dispatcher for interacting with a method handle lookup.-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ClassInjector.UsingInstrumentation, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe
-
-
Field Summary
-
Fields inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ALLOW_EXISTING_TYPES
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
UsingLookup(java.lang.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 java.util.Map<TypeDescription,java.lang.Class<?>>
inject(java.util.Map<? extends TypeDescription,byte[]> types)
Injects the given types into the represented class loader.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.
-
-
-
Method Detail
-
of
public static ClassInjector.UsingLookup of(java.lang.Object lookup)
Creates class injector that defines a class using a method handle lookup.- Parameters:
lookup
- Thejava.lang.invoke.MethodHandles$Lookup
instance to use.- Returns:
- An appropriate class injector.
-
isAvailable
public static boolean isAvailable()
Checks if the current VM is capable of defining classes using a method handle lookup.- Returns:
true
if the current VM is capable of defining classes using a lookup.
-
lookupType
public java.lang.Class<?> lookupType()
Returns the lookup type this injector is based upon.- Returns:
- The lookup type.
-
inject
public java.util.Map<TypeDescription,java.lang.Class<?>> inject(java.util.Map<? extends TypeDescription,byte[]> types)
Description copied from interface:ClassInjector
Injects the given types into the represented class loader.- Specified by:
inject
in interfaceClassInjector
- Parameters:
types
- The types to load via injection.- Returns:
- The loaded types that were passed as arguments.
-
-