Class ModuleLayerFromSingleClassLoaderDecorator

  • All Implemented Interfaces:
    ClassLoaderDecorator

    @Enhance
    public class ModuleLayerFromSingleClassLoaderDecorator
    extends java.lang.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 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 for java.security.AccessController#doPrivileged that 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:
        isSkipped in interface ClassLoaderDecorator
        Parameters:
        typeDescription - The type description to check.
        Returns:
        true if 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:
        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.