Class Advice.OffsetMapping.ForThisReference

java.lang.Object
net.bytebuddy.asm.Advice.OffsetMapping.ForThisReference
All Implemented Interfaces:
Advice.OffsetMapping
Enclosing interface:
Advice.OffsetMapping

@Enhance public static class Advice.OffsetMapping.ForThisReference extends Object implements Advice.OffsetMapping
An offset mapping that provides access to the this reference of the instrumented method.
  • Field Details

    • target

      private final TypeDescription.Generic target
      The type that the advice method expects for the this reference.
    • readOnly

      private final boolean readOnly
      Determines if the parameter is to be treated as read-only.
    • typing

      private final Assigner.Typing typing
      The typing to apply.
    • optional

      private final boolean optional
      true if the parameter should be bound to null if the instrumented method is static.
  • Constructor Details

    • ForThisReference

      protected ForThisReference(TypeDescription.Generic target, AnnotationDescription.Loadable<Advice.This> annotation)
      Creates a new offset mapping for a this reference.
      Parameters:
      target - The type that the advice method expects for the this reference.
      annotation - The mapped annotation.
    • ForThisReference

      public ForThisReference(TypeDescription.Generic target, boolean readOnly, Assigner.Typing typing, boolean optional)
      Creates a new offset mapping for a this reference.
      Parameters:
      target - The type that the advice method expects for the this reference.
      readOnly - Determines if the parameter is to be treated as read-only.
      typing - The typing to apply.
      optional - true if the parameter should be bound to null if the instrumented method is static.
  • Method Details

    • resolve

      public Advice.OffsetMapping.Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Advice.ArgumentHandler argumentHandler, Advice.OffsetMapping.Sort sort)
      Resolves an offset mapping to a given target offset.
      Specified by:
      resolve in interface Advice.OffsetMapping
      Parameters:
      instrumentedType - The instrumented type.
      instrumentedMethod - The instrumented method for which the mapping is to be resolved.
      assigner - The assigner to use.
      argumentHandler - The argument handler to use for resolving offsets of the local variable array of the instrumented method.
      sort - The sort of the advice method being resolved.
      Returns:
      A suitable target mapping.