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.
  • 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

    • isSkipped

      public boolean isSkipped(TypeDescription typeDescription)
      Determines if a type should be skipped from class loader decoration.
      Specified by:
      isSkipped in interface ClassLoaderDecorator
      Parameters:
      typeDescription - The type description to check.
      Returns:
      true if the type should be skipped from decoration.
    • apply

      @MaybeNull public ClassLoader apply(TypeDescription typeDescription)
      Applies this decorator to resolve a class loader for the given type.
      Specified by:
      apply in interface ClassLoaderDecorator
      Parameters:
      typeDescription - The type description for which to resolve a class loader.
      Returns:
      The class loader to use for the given type or null for the bootstrap class loader.