Class TypeWriter.MethodPool.Record.AccessBridgeWrapper

java.lang.Object
net.bytebuddy.dynamic.scaffold.TypeWriter.MethodPool.Record.AccessBridgeWrapper
All Implemented Interfaces:
TypeWriter.MethodPool.Record
Enclosing interface:
TypeWriter.MethodPool.Record

@Enhance public static class TypeWriter.MethodPool.Record.AccessBridgeWrapper extends Object implements TypeWriter.MethodPool.Record
A wrapper that appends accessor bridges for a method's implementation. The bridges are only added if TypeWriter.MethodPool.Record.apply(ClassVisitor, Implementation.Context, AnnotationValueFilter.Factory) is invoked such that bridges are not appended for methods that are rebased or redefined as such types already have bridge methods in place.
  • Field Details

    • delegate

      private final TypeWriter.MethodPool.Record delegate
      The delegate for implementing the bridge's target.
    • instrumentedType

      private final TypeDescription instrumentedType
      The instrumented type that defines the bridge methods and the bridge target.
    • bridgeTarget

      private final MethodDescription bridgeTarget
      The target of the bridge method.
    • bridgeTypes

      private final Set<MethodDescription.TypeToken> bridgeTypes
      A collection of all tokens representing all bridge methods.
    • attributeAppender

      private final MethodAttributeAppender attributeAppender
      The attribute appender being applied for the bridge target.
  • Constructor Details

    • AccessBridgeWrapper

      protected AccessBridgeWrapper(TypeWriter.MethodPool.Record delegate, TypeDescription instrumentedType, MethodDescription bridgeTarget, Set<MethodDescription.TypeToken> bridgeTypes, MethodAttributeAppender attributeAppender)
      Creates a wrapper for adding accessor bridges.
      Parameters:
      delegate - The delegate for implementing the bridge's target.
      instrumentedType - The instrumented type that defines the bridge methods and the bridge target.
      bridgeTarget - The target of the bridge method.
      bridgeTypes - A collection of all tokens representing all bridge methods.
      attributeAppender - The attribute appender being applied for the bridge target.
  • Method Details

    • of

      public static TypeWriter.MethodPool.Record of(TypeWriter.MethodPool.Record delegate, TypeDescription instrumentedType, MethodDescription bridgeTarget, Set<MethodDescription.TypeToken> bridgeTypes, MethodAttributeAppender attributeAppender)
      Wraps the given record in an accessor bridge wrapper if necessary.
      Parameters:
      delegate - The delegate for implementing the bridge's target.
      instrumentedType - The instrumented type that defines the bridge methods and the bridge target.
      bridgeTarget - The bridge methods' target methods.
      bridgeTypes - A collection of all tokens representing all bridge methods.
      attributeAppender - The attribute appender being applied for the bridge target.
      Returns:
      The given record wrapped by a bridge method wrapper if necessary.
    • getSort

      Returns the sort of this method instrumentation.
      Specified by:
      getSort in interface TypeWriter.MethodPool.Record
      Returns:
      The sort of this method instrumentation.
    • getMethod

      public MethodDescription getMethod()
      Returns the method that is implemented where the returned method resembles a potential transformation. An implemented method is only defined if a method is not TypeWriter.MethodPool.Record.Sort.SKIPPED.
      Specified by:
      getMethod in interface TypeWriter.MethodPool.Record
      Returns:
      The implemented method.
    • getVisibility

      public Visibility getVisibility()
      The visibility to enforce for this method.
      Specified by:
      getVisibility in interface TypeWriter.MethodPool.Record
      Returns:
      The visibility to enforce for this method.
    • prepend

      public TypeWriter.MethodPool.Record prepend(ByteCodeAppender byteCodeAppender)
      Prepends the given method appender to this entry.
      Specified by:
      prepend in interface TypeWriter.MethodPool.Record
      Parameters:
      byteCodeAppender - The byte code appender to prepend.
      Returns:
      This entry with the given code prepended.
    • apply

      public void apply(org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, AnnotationValueFilter.Factory annotationValueFilterFactory)
      Applies this method entry. This method can always be called and might be a no-op.
      Specified by:
      apply in interface TypeWriter.MethodPool.Record
      Parameters:
      classVisitor - The class visitor to which this entry should be applied.
      implementationContext - The implementation context to which this entry should be applied.
      annotationValueFilterFactory - The annotation value filter factory to apply when writing annotations.
    • applyHead

      public void applyHead(org.objectweb.asm.MethodVisitor methodVisitor)
      Applies the head of this entry. Applying an entry is only possible if a method is defined, i.e. the sort of this entry is not TypeWriter.MethodPool.Record.Sort.SKIPPED.
      Specified by:
      applyHead in interface TypeWriter.MethodPool.Record
      Parameters:
      methodVisitor - The method visitor to which this entry should be applied.
    • applyBody

      public void applyBody(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, AnnotationValueFilter.Factory annotationValueFilterFactory)
      Applies the body of this entry. Applying the body of an entry is only possible if a method is implemented, i.e. the sort of this entry is TypeWriter.MethodPool.Record.Sort.IMPLEMENTED.
      Specified by:
      applyBody in interface TypeWriter.MethodPool.Record
      Parameters:
      methodVisitor - The method visitor to which this entry should be applied.
      implementationContext - The implementation context to which this entry should be applied.
      annotationValueFilterFactory - The annotation value filter factory to apply when writing annotations.
    • applyAttributes

      public void applyAttributes(org.objectweb.asm.MethodVisitor methodVisitor, AnnotationValueFilter.Factory annotationValueFilterFactory)
      Applies the attributes of this entry. Applying the body of an entry is only possible if a method is implemented, i.e. the sort of this entry is TypeWriter.MethodPool.Record.Sort.DEFINED.
      Specified by:
      applyAttributes in interface TypeWriter.MethodPool.Record
      Parameters:
      methodVisitor - The method visitor to which this entry should be applied.
      annotationValueFilterFactory - The annotation value filter factory to apply when writing annotations.
    • applyCode

      public ByteCodeAppender.Size applyCode(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext)
      Applies the code of this entry. Applying the body of an entry is only possible if a method is implemented, i.e. the sort of this entry is TypeWriter.MethodPool.Record.Sort.IMPLEMENTED.
      Specified by:
      applyCode in interface TypeWriter.MethodPool.Record
      Parameters:
      methodVisitor - The method visitor to which this entry should be applied.
      implementationContext - The implementation context to which this entry should be applied.
      Returns:
      The size requirements of the implemented code.