@HashCodeAndEqualsPlugin.Enhance public static class ClassLoadingStrategy.UsingLookup extends Object implements ClassLoadingStrategy<ClassLoader>
java.lang.invoke.MethodHandles$Lookup
instance 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.ClassLoadingStrategy.Configurable<S extends ClassLoader>, ClassLoadingStrategy.Default, ClassLoadingStrategy.ForBootstrapInjection, ClassLoadingStrategy.ForJnaInjection, ClassLoadingStrategy.ForUnsafeInjection, ClassLoadingStrategy.UsingLookup
BOOTSTRAP_LOADER, NO_PROTECTION_DOMAIN
Modifier | Constructor and Description |
---|---|
protected |
UsingLookup(ClassInjector classInjector)
Creates a new class loading strategy that uses a lookup type.
|
Modifier and Type | Method and Description |
---|---|
Map<TypeDescription,Class<?>> |
load(ClassLoader classLoader,
Map<TypeDescription,byte[]> types)
Loads a given collection of classes given their binary representation.
|
static ClassLoadingStrategy<ClassLoader> |
of(Object lookup)
Creates a new class loading strategy that uses a
java.lang.invoke.MethodHandles$Lookup instance. |
static ClassLoadingStrategy<ClassLoader> |
withFallback(Callable<?> lookup)
Resolves a class loading strategy using a lookup if available on the current JVM.
|
static ClassLoadingStrategy<ClassLoader> |
withFallback(Callable<?> lookup,
boolean wrapper)
Resolves a class loading strategy using a lookup if available on the current JVM.
|
protected UsingLookup(ClassInjector classInjector)
classInjector
- The class injector to use.public static ClassLoadingStrategy<ClassLoader> of(Object lookup)
java.lang.invoke.MethodHandles$Lookup
instance.lookup
- The lookup instance to use for defining new types.public static ClassLoadingStrategy<ClassLoader> withFallback(Callable<?> lookup)
ClassLoadingStrategy.UsingLookup.withFallback(MethodHandles::lookup)
. Note that the invocation of
MethodHandles.lookup()
is call site sensitive such that it cannot be invoked within Byte Buddy what requires this
external invocation.lookup
- A resolver for a lookup instance if the current JVM allows for lookup-based class injection.public static ClassLoadingStrategy<ClassLoader> withFallback(Callable<?> lookup, boolean wrapper)
ClassLoadingStrategy.UsingLookup.withFallback(MethodHandles::lookup)
. Note that the invocation of
MethodHandles.lookup()
is call site sensitive such that it cannot be invoked within Byte Buddy what requires this
external invocation.lookup
- A resolver for a lookup instance if the current JVM allows for lookup-based class injection.wrapper
- true
if a ClassLoadingStrategy.Default.WRAPPER
strategy should be used as a fallback in case that no injection strategy is available.public Map<TypeDescription,Class<?>> load(@MaybeNull ClassLoader classLoader, Map<TypeDescription,byte[]> types)
load
in interface ClassLoadingStrategy<ClassLoader>
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.Copyright © 2014–2024. All rights reserved.