Package net.bytebuddy.asm
Class TypeReferenceAdjustment
java.lang.Object
net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
net.bytebuddy.asm.TypeReferenceAdjustment
- All Implemented Interfaces:
AsmVisitorWrapper
Adds an attribute value for all inner classes that are referenced by the instrumented type. Adding such attributes
is formally required by the Java virtual machine specification but it is not enforced by the verifier. As a result,
many alternative JVM languages do not correctly implement the attribute. By adding this visitor, a type's inner
class attribute can be repaired or created by registering this visitor wrapper.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A class visitor that collects all type references and all inner class references.Nested classes/interfaces inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
AsmVisitorWrapper.AbstractBase, AsmVisitorWrapper.Compound, AsmVisitorWrapper.ForDeclaredFields, AsmVisitorWrapper.ForDeclaredMethods, AsmVisitorWrapper.NoOp
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ElementMatcher.Junction<? super TypeDescription>
A filter for excluding types from type reference analysis.private final boolean
true
if the visitor should throw an exception if a type reference cannot be located.Fields inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
NO_FLAGS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TypeReferenceAdjustment
(boolean strict, ElementMatcher.Junction<? super TypeDescription> filter) Creates a type reference adjustment. -
Method Summary
Modifier and TypeMethodDescriptionfilter
(ElementMatcher<? super TypeDescription> filter) Excludes all matched types from being added as an attribute.static TypeReferenceAdjustment
relaxed()
Creates a strict type reference adjustment that ignores type references that cannot be resolved in the supplied type pool.static TypeReferenceAdjustment
strict()
Creates a strict type reference adjustment that throws an exception if a type reference cannot be resolved in the supplied type pool.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 Details
-
strict
private final boolean stricttrue
if the visitor should throw an exception if a type reference cannot be located. -
filter
A filter for excluding types from type reference analysis.
-
-
Constructor Details
-
TypeReferenceAdjustment
protected TypeReferenceAdjustment(boolean strict, ElementMatcher.Junction<? super TypeDescription> filter) Creates a type reference adjustment.- Parameters:
strict
-true
if the visitor should throw an exception if a type reference cannot be located.filter
- A filter for excluding types from type reference analysis.
-
-
Method Details
-
strict
Creates a strict type reference adjustment that throws an exception if a type reference cannot be resolved in the supplied type pool.- Returns:
- A strict type reference adjustment.
-
relaxed
Creates a strict type reference adjustment that ignores type references that cannot be resolved in the supplied type pool.- Returns:
- A relaxed type reference adjustment.
-
filter
Excludes all matched types from being added as an attribute.- Parameters:
filter
- A filter for excluding types from the attribute generation.- Returns:
- A new type reference adjustment that uses the supplied filter for excluding types.
-
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.
-