Package net.bytebuddy.build
Class AccessControllerPlugin
java.lang.Object
net.bytebuddy.build.Plugin.ForElementMatcher
net.bytebuddy.build.AccessControllerPlugin
- All Implemented Interfaces:
Closeable
,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
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
An wrapper for a method that represents a method ofAccessController
which is weaved.static @interface
Indicates that the annotated method represents a pseudo implementation ofjava.security.AccessController
which can be weaved to dispatch to the access controller if this is possible on the current VM and not explicitly disabled on the current VM via a system property.protected static class
A byte code appender to create an initializer segment that determines if thejava.security.AccessController
is available.Nested classes/interfaces inherited from interface net.bytebuddy.matcher.ElementMatcher
ElementMatcher.Junction<S>
Nested classes/interfaces inherited from interface net.bytebuddy.build.Plugin
Plugin.Engine, Plugin.Factory, Plugin.ForElementMatcher, Plugin.NoOp, Plugin.WithInitialization, Plugin.WithPreprocessor
Nested classes/interfaces inherited from interface net.bytebuddy.build.Plugin.Factory
Plugin.Factory.Simple, Plugin.Factory.UsingReflection
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The binary name ofjava.security.AccessController
.private static final Object[]
An empty array to create frames without additional allocation.private static final String
The name of the generated field.private final String
The property to control if the access controller should be used even if available ornull
if such a property should not be available.private static final Map
<MethodDescription.SignatureToken, MethodDescription.SignatureToken> A map to all signatures ofjava.security.AccessController
from a signature that does not contain any types that are deprecated for removal. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new plugin to weave access controller dispatches without a property to allow for disabling the access controller handling.AccessControllerPlugin
(String property) Creates a new plugin to weave access controller dispatches. -
Method Summary
Modifier and TypeMethodDescriptionapply
(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator) Applies this plugin.void
close()
make()
Returns a plugin that can be used for a transformation and which is subsequently closed.Methods inherited from class net.bytebuddy.build.Plugin.ForElementMatcher
matches
-
Field Details
-
ACCESS_CONTROLLER
The binary name ofjava.security.AccessController
.- See Also:
-
NAME
The name of the generated field.- See Also:
-
EMPTY
An empty array to create frames without additional allocation. -
SIGNATURES
private static final Map<MethodDescription.SignatureToken,MethodDescription.SignatureToken> SIGNATURESA map to all signatures ofjava.security.AccessController
from a signature that does not contain any types that are deprecated for removal. -
property
The property to control if the access controller should be used even if available ornull
if such a property should not be available.
-
-
Constructor Details
-
AccessControllerPlugin
public AccessControllerPlugin()Creates a new plugin to weave access controller dispatches without a property to allow for disabling the access controller handling. -
AccessControllerPlugin
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 ornull
if such a property should not be available.
-
-
Method Details
-
make
Returns a plugin that can be used for a transformation and which is subsequently closed.- Specified by:
make
in interfacePlugin.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 interfacePlugin
- 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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-