Package net.bytebuddy.dynamic.loading
Class ClassLoadingStrategy.Default.WrappingDispatcher
- java.lang.Object
-
- net.bytebuddy.dynamic.loading.ClassLoadingStrategy.Default.WrappingDispatcher
-
- All Implemented Interfaces:
ClassLoadingStrategy<java.lang.ClassLoader>,ClassLoadingStrategy.Configurable<java.lang.ClassLoader>
- Enclosing class:
- ClassLoadingStrategy.Default
@Enhance protected static class ClassLoadingStrategy.Default.WrappingDispatcher extends java.lang.Object implements ClassLoadingStrategy.Configurable<java.lang.ClassLoader>
A class loading strategy which creates a wrapping class loader while applying a givenProtectionDomainon class loading.
-
-
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 static booleanCHILD_FIRSTIndicates that a child first loading strategy should be attempted.private booleanchildFirsttrueif the created class loader should apply child-first semantics.private booleanforbidExistingDetermines if an exception should be thrown when attempting to load a type that already exists.private PackageDefinitionStrategypackageDefinitionStrategyThe package definer to be used for querying information on package information.private static booleanPARENT_FIRSTIndicates that a parent first loading strategy should be attempted.private ByteArrayClassLoader.PersistenceHandlerpersistenceHandlerThe persistence handler to apply.private java.security.ProtectionDomainprotectionDomainThe protection domain to apply ornullif no protection domain is set.private booleansealedtrueif the class loader should be sealed.-
Fields inherited from interface net.bytebuddy.dynamic.loading.ClassLoadingStrategy
BOOTSTRAP_LOADER, NO_PROTECTION_DOMAIN
-
-
Constructor Summary
Constructors Modifier Constructor Description privateWrappingDispatcher(java.security.ProtectionDomain protectionDomain, PackageDefinitionStrategy packageDefinitionStrategy, ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst, boolean forbidExisting, boolean sealed)Creates a new protection domain specific class loading wrapper.protectedWrappingDispatcher(ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst)Creates a new wrapping dispatcher with a default protection domain and a default access control context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassLoadingStrategy.Configurable<java.lang.ClassLoader>allowExistingTypes()Determines if this class loading strategy should not throw an exception when attempting to load a class that was already loaded.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.ClassLoadingStrategy.Configurable<java.lang.ClassLoader>opened()With an opened class loading strategy, it is assured that types can be added to the class loader, either by indirect injection using this strategy or by creating a class loader that explicitly supports injection.ClassLoadingStrategy.Configurable<java.lang.ClassLoader>with(java.security.ProtectionDomain protectionDomain)Overrides the implicitly set defaultProtectionDomainwith an explicit one.ClassLoadingStrategy.Configurable<java.lang.ClassLoader>with(PackageDefinitionStrategy packageDefinitionStrategy)Defines the supplied package definition strategy to be used for defining packages.
-
-
-
Field Detail
-
CHILD_FIRST
private static final boolean CHILD_FIRST
Indicates that a child first loading strategy should be attempted.- See Also:
- Constant Field Values
-
PARENT_FIRST
private static final boolean PARENT_FIRST
Indicates that a parent first loading strategy should be attempted.- See Also:
- Constant Field Values
-
protectionDomain
@ValueHandling(REVERSE_NULLABILITY) private final java.security.ProtectionDomain protectionDomain
The protection domain to apply ornullif no protection domain is set.
-
persistenceHandler
private final ByteArrayClassLoader.PersistenceHandler persistenceHandler
The persistence handler to apply.
-
packageDefinitionStrategy
private final PackageDefinitionStrategy packageDefinitionStrategy
The package definer to be used for querying information on package information.
-
childFirst
private final boolean childFirst
trueif the created class loader should apply child-first semantics.
-
forbidExisting
private final boolean forbidExisting
Determines if an exception should be thrown when attempting to load a type that already exists.
-
sealed
private final boolean sealed
trueif the class loader should be sealed.
-
-
Constructor Detail
-
WrappingDispatcher
protected WrappingDispatcher(ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst)
Creates a new wrapping dispatcher with a default protection domain and a default access control context.- Parameters:
persistenceHandler- The persistence handler to apply.childFirst-trueif the created class loader should apply child-first semantics.
-
WrappingDispatcher
private WrappingDispatcher(java.security.ProtectionDomain protectionDomain, PackageDefinitionStrategy packageDefinitionStrategy, ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst, boolean forbidExisting, boolean sealed)Creates a new protection domain specific class loading wrapper.- Parameters:
protectionDomain- The protection domain to apply ornullif no protection domain is set.packageDefinitionStrategy- The package definer to be used for querying information on package information.persistenceHandler- The persistence handler to apply.childFirst-trueif the created class loader should apply child-first semantics.forbidExisting- Determines if an exception should be thrown when attempting to load a type that already exists.sealed-trueif the class loader should be sealed.
-
-
Method Detail
-
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.
-
with
public ClassLoadingStrategy.Configurable<java.lang.ClassLoader> with(java.security.ProtectionDomain protectionDomain)
Overrides the implicitly set defaultProtectionDomainwith an explicit one.- Specified by:
within interfaceClassLoadingStrategy.Configurable<java.lang.ClassLoader>- Parameters:
protectionDomain- The protection domain to apply ornullif no protection domain is set.- Returns:
- This class loading strategy with an explicitly set
ProtectionDomain.
-
with
public ClassLoadingStrategy.Configurable<java.lang.ClassLoader> with(PackageDefinitionStrategy packageDefinitionStrategy)
Defines the supplied package definition strategy to be used for defining packages.- Specified by:
within interfaceClassLoadingStrategy.Configurable<java.lang.ClassLoader>- Parameters:
packageDefinitionStrategy- The package definer to be used.- Returns:
- A version of this class loading strategy that applies the supplied package definition strategy.
-
allowExistingTypes
public ClassLoadingStrategy.Configurable<java.lang.ClassLoader> allowExistingTypes()
Determines if this class loading strategy should not throw an exception when attempting to load a class that was already loaded. In this case, the already loaded class is used instead of the generated class.- Specified by:
allowExistingTypesin interfaceClassLoadingStrategy.Configurable<java.lang.ClassLoader>- Returns:
- A version of this class loading strategy that does not throw an exception when a class is already loaded.
-
opened
public ClassLoadingStrategy.Configurable<java.lang.ClassLoader> opened()
With an opened class loading strategy, it is assured that types can be added to the class loader, either by indirect injection using this strategy or by creating a class loader that explicitly supports injection.- Specified by:
openedin interfaceClassLoadingStrategy.Configurable<java.lang.ClassLoader>- Returns:
- A version of this class loading strategy that opens for future injections into a class loader.
-
-