Package net.bytebuddy.asm
Class TypeReferenceAdjustment
- java.lang.Object
-
- net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
-
- net.bytebuddy.asm.TypeReferenceAdjustment
-
- All Implemented Interfaces:
AsmVisitorWrapper
@Enhance public class TypeReferenceAdjustment extends AsmVisitorWrapper.AbstractBase
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 Classes Modifier and Type Class Description protected static classTypeReferenceAdjustment.TypeReferenceClassVisitorA 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
Fields Modifier and Type Field Description private ElementMatcher.Junction<? super TypeDescription>filterA filter for excluding types from type reference analysis.private booleanstricttrueif 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
Constructors Modifier Constructor Description protectedTypeReferenceAdjustment(boolean strict, ElementMatcher.Junction<? super TypeDescription> filter)Creates a type reference adjustment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeReferenceAdjustmentfilter(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 net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
mergeReader, mergeWriter
-
-
-
-
Field Detail
-
strict
private final boolean strict
trueif the visitor should throw an exception if a type reference cannot be located.
-
filter
private final ElementMatcher.Junction<? super TypeDescription> filter
A filter for excluding types from type reference analysis.
-
-
Constructor Detail
-
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 Detail
-
strict
public 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.- Returns:
- A strict type reference adjustment.
-
relaxed
public static TypeReferenceAdjustment 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
public TypeReferenceAdjustment filter(ElementMatcher<? super TypeDescription> 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.
-
-