Class AccessControllerPlugin

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Plugin, Plugin.Factory, ElementMatcher<TypeDescription>

    @Enhance
    public class AccessControllerPlugin
    extends Plugin.ForElementMatcher
    implements Plugin.Factory
    A build tool plugin that instruments methods to dispatch to methods java.security.AccessController with equal signature. This can be useful to avoid using types from the java.security package which were deprecated for removal in Java 17. Annotated methods are dispatched to the JVM's access controller only if this type is available on the current VM, and if no system property is added and set to disable such dispatch. In the process, java.security.AccessControlContext is represented by Object.
    • Field Detail

      • ACCESS_CONTROLLER

        private static final java.lang.String ACCESS_CONTROLLER
        The binary name of java.security.AccessController.
        See Also:
        Constant Field Values
      • NAME

        private static final java.lang.String NAME
        The name of the generated field.
        See Also:
        Constant Field Values
      • EMPTY

        private static final java.lang.Object[] EMPTY
        An empty array to create frames without additional allocation.
      • property

        @ValueHandling(REVERSE_NULLABILITY)
        private final java.lang.String property
        The property to control if the access controller should be used even if available or null if such a property should not be available.
    • Constructor Detail

      • AccessControllerPlugin

        public AccessControllerPlugin()
        Creates a new plugin to weave access controller dispatches without a property to allow for disabling the access controller handling.
      • AccessControllerPlugin

        @Priority(2147483647)
        public AccessControllerPlugin​(java.lang.String property)
        Creates a new plugin to weave access controller dispatches.
        Parameters:
        property - The property to control if the access controller should be used even if available or null if such a property should not be available.
    • Method Detail

      • make

        public Plugin make()
        Returns a plugin that can be used for a transformation and which is subsequently closed.
        Specified by:
        make in interface Plugin.Factory
        Returns:
        The plugin to use for type transformations.
      • apply

        public DynamicType.Builder<?> apply​(DynamicType.Builder<?> builder,
                                            TypeDescription typeDescription,
                                            ClassFileLocator classFileLocator)
        Applies this plugin.
        Specified by:
        apply in interface Plugin
        Parameters:
        builder - The builder to use as a basis for the applied transformation.
        typeDescription - The type being transformed.
        classFileLocator - A class file locator that can locate other types in the scope of the project.
        Returns:
        The supplied builder with additional transformations registered.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable