Class ModuleLayerFromSingleClassLoaderDecorator
java.lang.Object
net.bytebuddy.dynamic.loading.ModuleLayerFromSingleClassLoaderDecorator
- All Implemented Interfaces:
ClassLoaderDecorator
@Enhance
public class ModuleLayerFromSingleClassLoaderDecorator
extends Object
implements ClassLoaderDecorator
A simple implementation of a
ClassLoaderDecorator that creates module layers for dynamically
generated types using the Java Module System. The module information is resolved from a provided
module-info class. Without such a class, the decoration is omitted.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn abstract implementation of a module finder that can locate specific modules.static classAn abstract implementation of a module reader that provides access to dynamically generated types.protected static interfaceA proxy for thejava.lang.module.Configurationtype.static enumA factory for creating a single module from amodule-infoclass file, if available.protected static interfaceA proxy for thejava.lang.module.ModuleDescriptortype.protected static interfaceA proxy for thejava.lang.module.ModuleFindertype.protected static interfaceA proxy for thejava.lang.ModuleLayertype.protected static interfaceA proxy for thejava.lang.ModuleLayer.Controllertype.protected static interfaceA proxy for thejava.util.Optionaltype.protected static interfaceA proxy for thejava.nio.file.Pathtype.protected static interfaceA proxy for the dynamically generatedSimpleModuleFindertype.protected static interfaceA proxy for the dynamically generatedSimpleModuleReferencetype.protected static interfaceA proxy for thejava.util.stream.Streamtype.Nested classes/interfaces inherited from interface ClassLoaderDecorator
ClassLoaderDecorator.NoOp -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassLoaderThe class loader to delegate to when types are not handled by the module layer.private static final ModuleLayerFromSingleClassLoaderDecorator.ConfigurationA proxy forjava.lang.module.Configuration.private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleDescriptorA proxy forjava.lang.module.ModuleDescriptor.private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleFinderA proxy forjava.lang.module.ModuleFinder.private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleLayerA proxy forjava.lang.ModuleLayer.private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleLayerControllerA proxy forjava.lang.ModuleLayer.Controller.private final ObjectThe module layer containing the dynamically created module.private final StringThe name of the module within the module layer.private static final ModuleLayerFromSingleClassLoaderDecorator.OptionalA proxy forjava.util.Optional.The packages that are exported by the module.private static final ModuleLayerFromSingleClassLoaderDecorator.PathA proxy forjava.nio.file.Path.private static final ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleFinderA proxy for the dynamically generated simple module finder class.private static final ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleReferenceA proxy for the dynamically generated simple module reference class.private static final ModuleLayerFromSingleClassLoaderDecorator.StreamA proxy forjava.util.stream.Stream. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedModuleLayerFromSingleClassLoaderDecorator(ClassLoader classLoader, Object moduleLayer, String name, Set<String> packages) Creates a new module layer from module info decorator. -
Method Summary
Modifier and TypeMethodDescriptionapply(TypeDescription typeDescription) Applies this decorator to resolve a class loader for the given type.private static <T> TdoPrivileged(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.booleanisSkipped(TypeDescription typeDescription) Determines if a type should be skipped from class loader decoration.
-
Field Details
-
MODULE_FINDER
A proxy forjava.lang.module.ModuleFinder. -
MODULE_DESCRIPTOR
A proxy forjava.lang.module.ModuleDescriptor. -
MODULE_LAYER
A proxy forjava.lang.ModuleLayer. -
MODULE_LAYER_CONTROLLER
private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleLayerController MODULE_LAYER_CONTROLLERA proxy forjava.lang.ModuleLayer.Controller. -
CONFIGURATION
A proxy forjava.lang.module.Configuration. -
OPTIONAL
A proxy forjava.util.Optional. -
STREAM
A proxy forjava.util.stream.Stream. -
PATH
A proxy forjava.nio.file.Path. -
SIMPLE_MODULE_REFERENCE
private static final ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleReference SIMPLE_MODULE_REFERENCEA proxy for the dynamically generated simple module reference class. -
SIMPLE_MODULE_FINDER
private static final ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleFinder SIMPLE_MODULE_FINDERA proxy for the dynamically generated simple module finder class. -
classLoader
The class loader to delegate to when types are not handled by the module layer. -
moduleLayer
The module layer containing the dynamically created module. -
name
The name of the module within the module layer. -
packages
-
-
Constructor Details
-
ModuleLayerFromSingleClassLoaderDecorator
protected ModuleLayerFromSingleClassLoaderDecorator(@MaybeNull ClassLoader classLoader, Object moduleLayer, String name, Set<String> packages) Creates a new module layer from module info decorator.- Parameters:
classLoader- The class loader to delegate to when types are not handled by the module layer.moduleLayer- The module layer containing the dynamically created module.name- The name of the module within the module layer.packages- The packages that are exported by the module.
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.- Type Parameters:
T- The type of the action's resolved value.- Parameters:
action- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
isSkipped
Determines if a type should be skipped from class loader decoration.- Specified by:
isSkippedin interfaceClassLoaderDecorator- Parameters:
typeDescription- The type description to check.- Returns:
trueif the type should be skipped from decoration.
-
apply
Applies this decorator to resolve a class loader for the given type.- Specified by:
applyin interfaceClassLoaderDecorator- Parameters:
typeDescription- The type description for which to resolve a class loader.- Returns:
- The class loader to use for the given type or
nullfor the bootstrap class loader.
-