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.
  • Field Details

    • strict

      private final boolean strict
      true if 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 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

      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 a ClassVisitorWrapper to the creation of a DynamicType.
      Parameters:
      instrumentedType - The instrumented type.
      classVisitor - A ClassVisitor to become the new primary class visitor to which the created DynamicType 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 ASM ClassWriter flags to consider.
      readerFlags - The ASM ClassReader flags to consider.
      Returns:
      A new ClassVisitor that usually delegates to the ClassVisitor delivered in the argument.