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 classA class visitor that collects all type references and all inner class references.Nested classes/interfaces inherited from interface 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 booleantrueif the visitor should throw an exception if a type reference cannot be located.Fields inherited from interface AsmVisitorWrapper
NO_FLAGS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTypeReferenceAdjustment(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 TypeReferenceAdjustmentrelaxed()Creates a strict type reference adjustment that ignores type references that cannot be resolved in the supplied type pool.static TypeReferenceAdjustmentstrict()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.ClassVisitorwrap(TypeDescription instrumentedType, org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags) Applies aClassVisitorWrapperto the creation of aDynamicType.Methods inherited from class AsmVisitorWrapper.AbstractBase
mergeReader, mergeWriter
-
Field Details
-
strict
private final boolean stricttrueif 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-trueif 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 aClassVisitorWrapperto the creation of aDynamicType.- Parameters:
instrumentedType- The instrumented type.classVisitor- AClassVisitorto become the new primary class visitor to which the createdDynamicTypeis 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 ASMClassWriterflags to consider.readerFlags- The ASMClassReaderflags to consider.- Returns:
- A new
ClassVisitorthat usually delegates to theClassVisitordelivered in the argument.
-