A visitor wrapper that removes fields or methods that match a given ElementMatcher.
Important Note
This matcher is not capable of removing synthetic bridge methods which will be retained if they are declared by the same class. As bridge methods only invoke an overridden method, the dispatch should however not be influenced by their retention.
Important Note
The removal of the method is not reflected in the created net.'s
type description of the instrumented type.
| Modifier and Type | Class and Description |
|---|---|
| protected static class | MemberRemoval.MemberRemovingClassVisitor
A class visitor that removes members based on element matchers. |
| Modifier and Type | Field and Description |
|---|---|
| private final ElementMatcher. | fieldMatcher
The matcher that decides upon field removal. |
| private final ElementMatcher. | methodMatcher
The matcher that decides upon method removal. |
| Access | Constructor and Description |
|---|---|
| public | MemberRemoval()
Creates a new member removal instance that does not specify the removal of any methods. |
| protected | MemberRemoval(ElementMatcher.
The matcher that decides upon field removal. fieldMatcher,The matcher that decides upon field removal. methodMatcherCreates a new member removal instance. |
| Modifier and Type | Method and Description |
|---|---|
| public MemberRemoval | Returns: A new member removal instance that removes all previously specified members and any constructor that matches the specified matcher.The matcher that decides upon constructor removal. matcher)Specifies that any constructor that matches the specified matcher should be removed. |
| public MemberRemoval | Returns: A new member removal instance that removes all previously specified members and any fields that match the specified matcher.The matcher that decides upon field removal. matcher)Specifies that any field that matches the specified matcher should be removed. |
| public MemberRemoval | Returns: A new member removal instance that removes all previously specified members and any method or constructor that matches the specified matcher.The matcher that decides upon method and constructor removal. matcher)Specifies that any method or constructor that matches the specified matcher should be removed. |
| public MemberRemoval | Returns: A new member removal instance that removes all previously specified members and any method that matches the specified matcher.The matcher that decides upon method removal. matcher)Specifies that any method that matches the specified matcher should be removed. |
| public ClassVisitor | wrap(TypeDescription
The instrumented type. instrumentedType, ClassVisitor A classVisitor, Implementation.ClassVisitor to become the new primary class visitor to which the created
net. is written to.The implementation context of the current instrumentation. implementationContext,The type pool that was provided for the class creation. typePool, FieldList<FieldDescription.The instrumented type's fields. fields,The instrumented type's methods non-ignored declared and virtually inherited methods. methods, int The ASM writerFlags, int net. flags to consider.The ASM readerFlags)net. flags to consider.Implements net. ClassVisitorWrapper to the creation of a net..
|
| fieldMatcher | back to summary |
|---|---|
| private final ElementMatcher. The matcher that decides upon field removal. | |
| methodMatcher | back to summary |
|---|---|
| private final ElementMatcher. The matcher that decides upon method removal. | |
| MemberRemoval | back to summary |
|---|---|
| public MemberRemoval() Creates a new member removal instance that does not specify the removal of any methods. | |
| MemberRemoval | back to summary |
|---|---|
| protected MemberRemoval(ElementMatcher. Creates a new member removal instance.
| |
| stripConstructors | back to summary |
|---|---|
| public MemberRemoval stripConstructors(ElementMatcher<? super MethodDescription> matcher) Specifies that any constructor that matches the specified matcher should be removed.
| |
| stripFields | back to summary |
|---|---|
| public MemberRemoval stripFields(ElementMatcher<? super FieldDescription. Specifies that any field that matches the specified matcher should be removed.
| |
| stripInvokables | back to summary |
|---|---|
| public MemberRemoval stripInvokables(ElementMatcher<? super MethodDescription> matcher) Specifies that any method or constructor that matches the specified matcher should be removed. Note that this implementation will not strip bridge methods for virtual overrides of generic methods.
| |
| stripMethods | back to summary |
|---|---|
| public MemberRemoval stripMethods(ElementMatcher<? super MethodDescription> matcher) Specifies that any method that matches the specified matcher should be removed. Note that this implementation will not strip bridge methods for virtual overrides of generic methods.
| |
| wrap | back to summary |
|---|---|
| public ClassVisitor wrap(TypeDescription instrumentedType, ClassVisitor classVisitor, Implementation. Implements net. Doc from net. Applies a
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ElementMatcher. | fieldMatcher
The matcher that determines field removal. |
| private final Map | fields
A mapping of field names and descriptors to their description. |
| private final ElementMatcher. | methodMatcher
The matcher that determines method removal. |
| private final Map | methods
A mapping of method names and descriptors to their description. |
| private static final FieldVisitor | REMOVE_FIELD
Indicates the removal of a field. |
| private static final MethodVisitor | REMOVE_METHOD
Indicates the removal of a method. |
| Access | Constructor and Description |
|---|---|
| protected | MemberRemovingClassVisitor(ClassVisitor
The class visitor to delegate to. classVisitor, ElementMatcher.The matcher that determines field removal. fieldMatcher,The matcher that determines method removal. methodMatcher,A mapping of field names and descriptors to their description. fields,A mapping of method names and descriptors to their description. methods)Creates a new member removing class visitor. |
| Modifier and Type | Method and Description |
|---|---|
| public FieldVisitor | visitField(int
the field's access flags (see modifiers, String Opcodes). This parameter also indicates if
the field is synthetic and/or deprecated.the field's name. internalName, String the field's descriptor (see descriptor, String Type).the field's signature. May be null if the field's type does not use
generic types. signature, Object the field's initial value. This parameter, which may be null if the
field does not have an initial value, must be an value)
Visits a field of the class.
Integer, a Float, a Long, a Double or a String (for int, float, long
or String fields respectively). This parameter is only used for static
fields. Its value is ignored for non static fields, which must be initialized through
bytecode instructions in constructors or methods. |
| public MethodVisitor | visitMethod(int
the method's access flags (see modifiers, String Opcodes). This parameter also indicates if
the method is synthetic and/or deprecated.the method's name. internalName, String the method's descriptor (see descriptor, String Type).the method's signature. May be null if the method parameters,
return type and exceptions do not use generic types. signature, String[] the internal names of the method's exception classes (see exception)
Visits a method of the class.
Type#getInternalName()). May be null. |
| fieldMatcher | back to summary |
|---|---|
| private final ElementMatcher. The matcher that determines field removal. | |
| fields | back to summary |
|---|---|
| private final Map<String, FieldDescription. A mapping of field names and descriptors to their description. | |
| methodMatcher | back to summary |
|---|---|
| private final ElementMatcher. The matcher that determines method removal. | |
| methods | back to summary |
|---|---|
| private final Map<String, MethodDescription> methods A mapping of method names and descriptors to their description. | |
| REMOVE_FIELD | back to summary |
|---|---|
| private static final FieldVisitor REMOVE_FIELD Indicates the removal of a field. | |
| REMOVE_METHOD | back to summary |
|---|---|
| private static final MethodVisitor REMOVE_METHOD Indicates the removal of a method. | |
| MemberRemovingClassVisitor | back to summary |
|---|---|
| protected MemberRemovingClassVisitor(ClassVisitor classVisitor, ElementMatcher. Creates a new member removing class visitor.
| |
| visitField | back to summary |
|---|---|
| public FieldVisitor visitField(int modifiers, String internalName, String descriptor, String signature, Object value) Overrides net. Doc from net. Visits a field of the class.
| |
| visitMethod | back to summary |
|---|---|
| public MethodVisitor visitMethod(int modifiers, String internalName, String descriptor, String signature, String[] exception) Overrides net. Doc from net. Visits a method of the class. This method must return a new
| |