Package net.bytebuddy.dynamic.loading
Class ClassLoadingStrategy.UsingLookup
- java.lang.Object
-
- net.bytebuddy.dynamic.loading.ClassLoadingStrategy.UsingLookup
-
- All Implemented Interfaces:
ClassLoadingStrategy<java.lang.ClassLoader>
- Enclosing interface:
- ClassLoadingStrategy<T extends java.lang.ClassLoader>
@Enhance public static class ClassLoadingStrategy.UsingLookup extends java.lang.Object implements ClassLoadingStrategy<java.lang.ClassLoader>
A class loading strategy that uses ajava.lang.invoke.MethodHandles$Lookupinstance for defining types. A lookup instance can define types only in the same class loader and in the same package as the type within which it was created. The supplied lookup must have package privileges, i.e. it must not be a public lookup.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassLoadingStrategy
ClassLoadingStrategy.Configurable<S extends java.lang.ClassLoader>, ClassLoadingStrategy.Default, ClassLoadingStrategy.ForBootstrapInjection, ClassLoadingStrategy.ForUnsafeInjection, ClassLoadingStrategy.UsingLookup
-
-
Field Summary
Fields Modifier and Type Field Description private ClassInjectorclassInjectorThe class injector to use.-
Fields inherited from interface net.bytebuddy.dynamic.loading.ClassLoadingStrategy
BOOTSTRAP_LOADER, NO_PROTECTION_DOMAIN
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedUsingLookup(ClassInjector classInjector)Creates a new class loading strategy that uses a lookup type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<TypeDescription,java.lang.Class<?>>load(java.lang.ClassLoader classLoader, java.util.Map<TypeDescription,byte[]> types)Loads a given collection of classes given their binary representation.static ClassLoadingStrategy<java.lang.ClassLoader>of(java.lang.Object lookup)Creates a new class loading strategy that uses ajava.lang.invoke.MethodHandles$Lookupinstance.
-
-
-
Field Detail
-
classInjector
private final ClassInjector classInjector
The class injector to use.
-
-
Constructor Detail
-
UsingLookup
protected UsingLookup(ClassInjector classInjector)
Creates a new class loading strategy that uses a lookup type.- Parameters:
classInjector- The class injector to use.
-
-
Method Detail
-
of
public static ClassLoadingStrategy<java.lang.ClassLoader> of(java.lang.Object lookup)
Creates a new class loading strategy that uses ajava.lang.invoke.MethodHandles$Lookupinstance.- Parameters:
lookup- The lookup instance to use for defining new types.- Returns:
- A suitable class loading strategy.
-
load
public java.util.Map<TypeDescription,java.lang.Class<?>> load(java.lang.ClassLoader classLoader, java.util.Map<TypeDescription,byte[]> types)
Loads a given collection of classes given their binary representation.- Specified by:
loadin interfaceClassLoadingStrategy<java.lang.ClassLoader>- Parameters:
classLoader- The class loader to used for loading the classes.types- Byte array representations of the types to be loaded mapped by their descriptions, where an iteration order defines an order in which they are supposed to be loaded, if relevant.- Returns:
- A collection of the loaded classes which will be initialized in the iteration order of the returned collection.
-
-