Package net.bytebuddy.asm
Class AnnotationRemoval
- java.lang.Object
-
- net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
-
- net.bytebuddy.asm.AnnotationRemoval
-
- All Implemented Interfaces:
AsmVisitorWrapper
@Enhance public class AnnotationRemoval extends AsmVisitorWrapper.AbstractBase
A visitor wrapper that removes annotations from the instrumented type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AnnotationRemoval.AnnotationRemovingClassVisitor
A class visitor that removes annotations.private static class
AnnotationRemoval.AnnotationRemovingFieldVisitor
A field visitor that removes annotations.private static class
AnnotationRemoval.AnnotationRemovingMethodVisitor
Creates a visitor for removing annotations from methods and method parameters.-
Nested classes/interfaces inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
AsmVisitorWrapper.AbstractBase, AsmVisitorWrapper.Compound, AsmVisitorWrapper.ForDeclaredFields, AsmVisitorWrapper.ForDeclaredMethods, AsmVisitorWrapper.NoOp
-
-
Field Summary
Fields Modifier and Type Field Description private ElementMatcher<? super AnnotationDescription>
annotationMatcher
Matches annotations that should be removed.private ElementMatcher<? super FieldDescription.InDefinedShape>
fieldMatcher
Matches fields from which annotations should be removed.private static int
METHOD_ALL
Indicates that bother method annotations and method parameter annotations should be considered.private static int
METHOD_NONE
Indicates that neither method annotations and method parameter annotations should be considered.private static int
METHOD_ONLY
Indicates that only method annotations should be considered.private static int
METHOD_PARAMETERS
Indicates that only method parameter annotations should be considered.private ElementMatcher<? super MethodDescription>
methodMatcher
Matches methods from which annotations should be removed.private int
parameters
Indices the method parameter index from which annotations should be removed, or a negative value to indicate different treatment.private boolean
type
true
if annotations on the type should be removed.-
Fields inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
NO_FLAGS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AnnotationRemoval(boolean type, ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, ElementMatcher<? super AnnotationDescription> annotationMatcher, int parameters)
Creates a visitor for annotation removal.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AsmVisitorWrapper
onConstructorParameter(ElementMatcher<? super MethodDescription> matcher, int parameter)
Creates a visitor that removes annotations from the constructor parameters with the given index where the constructor matches the specified matcher.AsmVisitorWrapper
onConstructorParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructor parameters where the constructor matches the specified matcher.AsmVisitorWrapper
onConstructors(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors that match the specified matcher.AsmVisitorWrapper
onConstructorsAndParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors and their parameters that match the specified matcher.AsmVisitorWrapper
onFields(ElementMatcher<? super FieldDescription> matcher)
Creates a visitor that only removes annotations from fields that match the specified matcher.AsmVisitorWrapper
onInvokableParameter(ElementMatcher<? super MethodDescription> matcher, int parameter)
Creates a visitor that removes annotations from the constructor or method parameters with the given index where the constructor or method matches the specified matcher.AsmVisitorWrapper
onInvokableParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructor or method parameters where the constructor or method matches the specified matcher.AsmVisitorWrapper
onInvokables(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors or methods that match the specified matcher.AsmVisitorWrapper
onInvokablesAndParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors or methods and their parameters that match the specified matcher.AsmVisitorWrapper
onMethodParameter(ElementMatcher<? super MethodDescription> matcher, int parameter)
Creates a visitor that removes annotations from the method parameters with the given index where the method matches the specified matcher.AsmVisitorWrapper
onMethodParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from method parameters where the method matches the specified matcher.AsmVisitorWrapper
onMethods(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from methods that match the specified matcher.AsmVisitorWrapper
onMethodsAndParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from methods and their parameters that match the specified matcher.AsmVisitorWrapper
onType()
Creates a visitor that only removes annotations from the type.static AnnotationRemoval
strip(ElementMatcher<? super AnnotationDescription> matcher)
Creates a visitor that removes all annotations that match the specified matcher from the instrumented type.org.objectweb.asm.ClassVisitor
wrap(TypeDescription instrumentedType, org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags)
Applies aClassVisitorWrapper
to the creation of aDynamicType
.-
Methods inherited from class net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
mergeReader, mergeWriter
-
-
-
-
Field Detail
-
METHOD_NONE
private static final int METHOD_NONE
Indicates that neither method annotations and method parameter annotations should be considered.- See Also:
- Constant Field Values
-
METHOD_ALL
private static final int METHOD_ALL
Indicates that bother method annotations and method parameter annotations should be considered.- See Also:
- Constant Field Values
-
METHOD_ONLY
private static final int METHOD_ONLY
Indicates that only method annotations should be considered.- See Also:
- Constant Field Values
-
METHOD_PARAMETERS
private static final int METHOD_PARAMETERS
Indicates that only method parameter annotations should be considered.- See Also:
- Constant Field Values
-
type
private final boolean type
true
if annotations on the type should be removed.
-
fieldMatcher
private final ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher
Matches fields from which annotations should be removed.
-
methodMatcher
private final ElementMatcher<? super MethodDescription> methodMatcher
Matches methods from which annotations should be removed.
-
annotationMatcher
private final ElementMatcher<? super AnnotationDescription> annotationMatcher
Matches annotations that should be removed.
-
parameters
private final int parameters
Indices the method parameter index from which annotations should be removed, or a negative value to indicate different treatment.
-
-
Constructor Detail
-
AnnotationRemoval
protected AnnotationRemoval(boolean type, ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, ElementMatcher<? super AnnotationDescription> annotationMatcher, int parameters)
Creates a visitor for annotation removal.- Parameters:
type
-true
if annotations on the type should be removed.fieldMatcher
- Matches fields from which annotations should be removed.methodMatcher
- Matches methods from which annotations should be removed.annotationMatcher
- Matches annotations that should be removed.parameters
- Indices the method parameter index from which annotations should be removed, or a negative value to indicate different treatment.
-
-
Method Detail
-
strip
public static AnnotationRemoval strip(ElementMatcher<? super AnnotationDescription> matcher)
Creates a visitor that removes all annotations that match the specified matcher from the instrumented type.- Parameters:
matcher
- The matcher to indicate what annotations to remove.- Returns:
- A visitor that removes the specified annotations.
-
onType
public AsmVisitorWrapper onType()
Creates a visitor that only removes annotations from the type.- Returns:
- An appropriate visitor for annotation removal.
-
onFields
public AsmVisitorWrapper onFields(ElementMatcher<? super FieldDescription> matcher)
Creates a visitor that only removes annotations from fields that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what fields annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethods
public AsmVisitorWrapper onMethods(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from methods that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethodsAndParameters
public AsmVisitorWrapper onMethodsAndParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from methods and their parameters that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethodParameters
public AsmVisitorWrapper onMethodParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from method parameters where the method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onMethodParameter
public AsmVisitorWrapper onMethodParameter(ElementMatcher<? super MethodDescription> matcher, int parameter)
Creates a visitor that removes annotations from the method parameters with the given index where the method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what methods annotations should be removed.parameter
- The index of the parameter of which to remove annotations.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructors
public AsmVisitorWrapper onConstructors(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructorsAndParameters
public AsmVisitorWrapper onConstructorsAndParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors and their parameters that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructorParameters
public AsmVisitorWrapper onConstructorParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructor parameters where the constructor matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onConstructorParameter
public AsmVisitorWrapper onConstructorParameter(ElementMatcher<? super MethodDescription> matcher, int parameter)
Creates a visitor that removes annotations from the constructor parameters with the given index where the constructor matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors annotations should be removed.parameter
- The index of the parameter of which to remove annotations.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokables
public AsmVisitorWrapper onInvokables(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors or methods that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokablesAndParameters
public AsmVisitorWrapper onInvokablesAndParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructors or methods and their parameters that match the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokableParameters
public AsmVisitorWrapper onInvokableParameters(ElementMatcher<? super MethodDescription> matcher)
Creates a visitor that removes annotations from constructor or method parameters where the constructor or method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.- Returns:
- An appropriate visitor for annotation removal.
-
onInvokableParameter
public AsmVisitorWrapper onInvokableParameter(ElementMatcher<? super MethodDescription> matcher, int parameter)
Creates a visitor that removes annotations from the constructor or method parameters with the given index where the constructor or method matches the specified matcher.- Parameters:
matcher
- A matcher that indicates from what constructors or methods annotations should be removed.parameter
- The index of the parameter of which to remove annotations.- Returns:
- An appropriate visitor for annotation removal.
-
wrap
public org.objectweb.asm.ClassVisitor wrap(TypeDescription instrumentedType, org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags)
Applies aClassVisitorWrapper
to the creation of aDynamicType
.- Parameters:
instrumentedType
- The instrumented type.classVisitor
- AClassVisitor
to become the new primary class visitor to which the createdDynamicType
is written to.implementationContext
- The implementation context of the current instrumentation.typePool
- The type pool that was provided for the class creation.fields
- The instrumented type's fields.methods
- The instrumented type's methods non-ignored declared and virtually inherited methods.writerFlags
- The ASMClassWriter
flags to consider.readerFlags
- The ASMClassReader
flags to consider.- Returns:
- A new
ClassVisitor
that usually delegates to theClassVisitor
delivered in the argument.
-
-