public static enum ClassLoadingStrategy.Default extends Enum<ClassLoadingStrategy.Default> implements ClassLoadingStrategy
WRAPPER
strategy
will create a new ByteArrayClassLoader
which
has the given class loader as its parent. The byte array class loader is aware of a given number of types
and can natively load the given classes. This allows to load classes with cyclic dependencies since the byte
array class loader is queried on each encountered unknown class. Due to the encapsulation of the
classes that were loaded by a byte array class loader, this strategy will lead to the unloading of these
classes once this class loader, its classes or any instances of these classes become unreachable.INJECTION
strategy
will not create a new class loader but inject all classes into the given ClassLoader
by
reflective access. This prevents the loading of classes with cyclic dependencies but avoids the creation of
an additional class loader. The advantage of this strategy is that the loaded classes will have package-private
access to other classes within their package of the class loader into which they are injected what is not
permitted when the wrapper class loader is used. This strategy is implemented using a
ClassLoaderByteArrayInjector
.ClassLoadingStrategy.Default
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.Default |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ClassLoadingStrategy.Default[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ClassLoadingStrategy.Default WRAPPER
public static final ClassLoadingStrategy.Default INJECTION
public static ClassLoadingStrategy.Default[] values()
for (ClassLoadingStrategy.Default c : ClassLoadingStrategy.Default.values()) System.out.println(c);
public static ClassLoadingStrategy.Default valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic Map<TypeDescription,Class<?>> load(ClassLoader classLoader, Map<TypeDescription,byte[]> types)
ClassLoadingStrategy
load
in interface ClassLoadingStrategy
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. All rights reserved.