Class AsmVisitorWrapper.ForDeclaredMethods

java.lang.Object
net.bytebuddy.asm.AsmVisitorWrapper.ForDeclaredMethods
All Implemented Interfaces:
AsmVisitorWrapper
Enclosing interface:
AsmVisitorWrapper

@Enhance public static class AsmVisitorWrapper.ForDeclaredMethods extends Object implements AsmVisitorWrapper

An ASM visitor wrapper that allows to wrap declared methods of the instrumented type with a AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper.

Note: Inherited methods are not matched by this visitor, even if they are intercepted by a normal interception.

  • Field Details

    • entries

      The list of entries that describe matched methods in their application order.
    • writerFlags

      private final int writerFlags
      The writer flags to set.
    • readerFlags

      private final int readerFlags
      The reader flags to set.
  • Constructor Details

    • ForDeclaredMethods

      public ForDeclaredMethods()
      Creates a new visitor wrapper for declared methods.
    • ForDeclaredMethods

      protected ForDeclaredMethods(List<AsmVisitorWrapper.ForDeclaredMethods.Entry> entries, int writerFlags, int readerFlags)
      Creates a new visitor wrapper for declared methods.
      Parameters:
      entries - The list of entries that describe matched methods in their application order.
      writerFlags - The writer flags to set.
      readerFlags - The reader flags to set.
  • Method Details

    • method

      Defines a new method visitor wrapper to be applied on any method if the given method matcher is matched. Previously defined entries are applied before the given matcher is applied.
      Parameters:
      matcher - The matcher to identify methods to be wrapped.
      methodVisitorWrapper - The method visitor wrapper to be applied if the given matcher is matched.
      Returns:
      A new ASM visitor wrapper that applied the given method visitor wrapper if the supplied matcher is matched.
    • method

      Defines a new method visitor wrapper to be applied on any method if the given method matcher is matched. Previously defined entries are applied before the given matcher is applied.
      Parameters:
      matcher - The matcher to identify methods to be wrapped.
      methodVisitorWrappers - The method visitor wrapper to be applied if the given matcher is matched.
      Returns:
      A new ASM visitor wrapper that applied the given method visitor wrapper if the supplied matcher is matched.
    • constructor

      Defines a new method visitor wrapper to be applied on any constructor if the given method matcher is matched. Previously defined entries are applied before the given matcher is applied.
      Parameters:
      matcher - The matcher to identify constructors to be wrapped.
      methodVisitorWrapper - The method visitor wrapper to be applied if the given matcher is matched.
      Returns:
      A new ASM visitor wrapper that applied the given method visitor wrapper if the supplied matcher is matched.
    • constructor

      Defines a new method visitor wrapper to be applied on any constructor if the given method matcher is matched. Previously defined entries are applied before the given matcher is applied.
      Parameters:
      matcher - The matcher to identify constructors to be wrapped.
      methodVisitorWrappers - The method visitor wrapper to be applied if the given matcher is matched.
      Returns:
      A new ASM visitor wrapper that applied the given method visitor wrapper if the supplied matcher is matched.
    • invokable

      Defines a new method visitor wrapper to be applied on any method or constructor if the given method matcher is matched. Previously defined entries are applied before the given matcher is applied.
      Parameters:
      matcher - The matcher to identify methods or constructors to be wrapped.
      methodVisitorWrapper - The method visitor wrapper to be applied if the given matcher is matched.
      Returns:
      A new ASM visitor wrapper that applied the given method visitor wrapper if the supplied matcher is matched.
    • invokable

      Defines a new method visitor wrapper to be applied on any method or constructor if the given method matcher is matched. Previously defined entries are applied before the given matcher is applied.
      Parameters:
      matcher - The matcher to identify methods or constructors to be wrapped.
      methodVisitorWrappers - The method visitor wrapper to be applied if the given matcher is matched.
      Returns:
      A new ASM visitor wrapper that applied the given method visitor wrapper if the supplied matcher is matched.
    • writerFlags

      public AsmVisitorWrapper.ForDeclaredMethods writerFlags(int flags)
      Sets flags for the ClassWriter this wrapper is applied to.
      Parameters:
      flags - The flags to set for the ClassWriter.
      Returns:
      A new ASM visitor wrapper that sets the supplied writer flags.
    • readerFlags

      public AsmVisitorWrapper.ForDeclaredMethods readerFlags(int flags)
      Sets flags for the ClassReader this wrapper is applied to.
      Parameters:
      flags - The flags to set for the ClassReader.
      Returns:
      A new ASM visitor wrapper that sets the supplied reader flags.
    • mergeWriter

      public int mergeWriter(int flags)
      Defines the flags that are provided to any ClassWriter when writing a class. Typically, this gives opportunity to instruct ASM to compute stack map frames or the size of the local variables array and the operand stack. If no specific flags are required for applying this wrapper, the given value is to be returned.
      Specified by:
      mergeWriter in interface AsmVisitorWrapper
      Parameters:
      flags - The currently set flags. This value should be combined (e.g. flags | foo) into the value that is returned by this wrapper.
      Returns:
      The flags to be provided to the ASM ClassWriter.
    • mergeReader

      public int mergeReader(int flags)
      Defines the flags that are provided to any ClassReader when reading a class if applicable. Typically, this gives opportunity to instruct ASM to expand or skip frames and to skip code and debug information. If no specific flags are required for applying this wrapper, the given value is to be returned.
      Specified by:
      mergeReader in interface AsmVisitorWrapper
      Parameters:
      flags - The currently set flags. This value should be combined (e.g. flags | foo) into the value that is returned by this wrapper.
      Returns:
      The flags to be provided to the ASM ClassReader.
    • 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.
      Specified by:
      wrap in interface AsmVisitorWrapper
      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.