Package net.bytebuddy.dynamic.loading
Class ModuleLayerFromSingleClassLoaderDecorator
- java.lang.Object
-
- net.bytebuddy.dynamic.loading.ModuleLayerFromSingleClassLoaderDecorator
-
- All Implemented Interfaces:
ClassLoaderDecorator
@Enhance public class ModuleLayerFromSingleClassLoaderDecorator extends java.lang.Object implements ClassLoaderDecorator
A simple implementation of aClassLoaderDecoratorthat creates module layers for dynamically generated types using the Java Module System. The module information is resolved from a providedmodule-infoclass. Without such a class, the decoration is omitted.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classModuleLayerFromSingleClassLoaderDecorator.AbstractModuleFinderAn abstract implementation of a module finder that can locate specific modules.static classModuleLayerFromSingleClassLoaderDecorator.AbstractModuleReaderAn abstract implementation of a module reader that provides access to dynamically generated types.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.ConfigurationA proxy for thejava.lang.module.Configurationtype.static classModuleLayerFromSingleClassLoaderDecorator.FactoryA factory for creating a single module from amodule-infoclass file, if available.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.ModuleDescriptorA proxy for thejava.lang.module.ModuleDescriptortype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.ModuleFinderA proxy for thejava.lang.module.ModuleFindertype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.ModuleLayerA proxy for thejava.lang.ModuleLayertype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.ModuleLayerControllerA proxy for thejava.lang.ModuleLayer.Controllertype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.OptionalA proxy for thejava.util.Optionaltype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.PathA proxy for thejava.nio.file.Pathtype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.SimpleModuleFinderA proxy for the dynamically generatedSimpleModuleFindertype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.SimpleModuleReferenceA proxy for the dynamically generatedSimpleModuleReferencetype.protected static interfaceModuleLayerFromSingleClassLoaderDecorator.StreamA proxy for thejava.util.stream.Streamtype.-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassLoaderDecorator
ClassLoaderDecorator.NoOp
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ClassLoaderclassLoaderThe class loader to delegate to when types are not handled by the module layer.private static ModuleLayerFromSingleClassLoaderDecorator.ConfigurationCONFIGURATIONA proxy forjava.lang.module.Configuration.private static ModuleLayerFromSingleClassLoaderDecorator.ModuleDescriptorMODULE_DESCRIPTORA proxy forjava.lang.module.ModuleDescriptor.private static ModuleLayerFromSingleClassLoaderDecorator.ModuleFinderMODULE_FINDERA proxy forjava.lang.module.ModuleFinder.private static ModuleLayerFromSingleClassLoaderDecorator.ModuleLayerMODULE_LAYERA proxy forjava.lang.ModuleLayer.private static ModuleLayerFromSingleClassLoaderDecorator.ModuleLayerControllerMODULE_LAYER_CONTROLLERA proxy forjava.lang.ModuleLayer.Controller.private java.lang.ObjectmoduleLayerThe module layer containing the dynamically created module.private java.lang.StringnameThe name of the module within the module layer.private static ModuleLayerFromSingleClassLoaderDecorator.OptionalOPTIONALA proxy forjava.util.Optional.private java.util.Set<java.lang.String>packagesThe packages that are exported by the module.private static ModuleLayerFromSingleClassLoaderDecorator.PathPATHA proxy forjava.nio.file.Path.private static ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleFinderSIMPLE_MODULE_FINDERA proxy for the dynamically generated simple module finder class.private static ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleReferenceSIMPLE_MODULE_REFERENCEA proxy for the dynamically generated simple module reference class.private static ModuleLayerFromSingleClassLoaderDecorator.StreamSTREAMA proxy forjava.util.stream.Stream.
-
Constructor Summary
Constructors Modifier Constructor Description protectedModuleLayerFromSingleClassLoaderDecorator(java.lang.ClassLoader classLoader, java.lang.Object moduleLayer, java.lang.String name, java.util.Set<java.lang.String> packages)Creates a new module layer from module info decorator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ClassLoaderapply(TypeDescription typeDescription)Applies this decorator to resolve a class loader for the given type.private static <T> TdoPrivileged(java.security.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 Detail
-
MODULE_FINDER
private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleFinder MODULE_FINDER
A proxy forjava.lang.module.ModuleFinder.
-
MODULE_DESCRIPTOR
private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleDescriptor MODULE_DESCRIPTOR
A proxy forjava.lang.module.ModuleDescriptor.
-
MODULE_LAYER
private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleLayer MODULE_LAYER
A proxy forjava.lang.ModuleLayer.
-
MODULE_LAYER_CONTROLLER
private static final ModuleLayerFromSingleClassLoaderDecorator.ModuleLayerController MODULE_LAYER_CONTROLLER
A proxy forjava.lang.ModuleLayer.Controller.
-
CONFIGURATION
private static final ModuleLayerFromSingleClassLoaderDecorator.Configuration CONFIGURATION
A proxy forjava.lang.module.Configuration.
-
OPTIONAL
private static final ModuleLayerFromSingleClassLoaderDecorator.Optional OPTIONAL
A proxy forjava.util.Optional.
-
STREAM
private static final ModuleLayerFromSingleClassLoaderDecorator.Stream STREAM
A proxy forjava.util.stream.Stream.
-
PATH
private static final ModuleLayerFromSingleClassLoaderDecorator.Path PATH
A proxy forjava.nio.file.Path.
-
SIMPLE_MODULE_REFERENCE
private static final ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleReference SIMPLE_MODULE_REFERENCE
A proxy for the dynamically generated simple module reference class.
-
SIMPLE_MODULE_FINDER
private static final ModuleLayerFromSingleClassLoaderDecorator.SimpleModuleFinder SIMPLE_MODULE_FINDER
A proxy for the dynamically generated simple module finder class.
-
classLoader
@MaybeNull @ValueHandling(REVERSE_NULLABILITY) private final java.lang.ClassLoader classLoader
The class loader to delegate to when types are not handled by the module layer.
-
moduleLayer
private final java.lang.Object moduleLayer
The module layer containing the dynamically created module.
-
name
private final java.lang.String name
The name of the module within the module layer.
-
packages
private final java.util.Set<java.lang.String> packages
The packages that are exported by the module.
-
-
Constructor Detail
-
ModuleLayerFromSingleClassLoaderDecorator
protected ModuleLayerFromSingleClassLoaderDecorator(@MaybeNull java.lang.ClassLoader classLoader, java.lang.Object moduleLayer, java.lang.String name, java.util.Set<java.lang.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 Detail
-
doPrivileged
@Enhance private static <T> T doPrivileged(java.security.PrivilegedAction<T> action)
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
public boolean isSkipped(TypeDescription typeDescription)
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
@MaybeNull public java.lang.ClassLoader apply(TypeDescription typeDescription)
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.
-
-