Class TypeWriter.MethodPool.Record.ForDefinedMethod.OfVisibilityBridge

java.lang.Object
net.bytebuddy.dynamic.scaffold.TypeWriter.MethodPool.Record.ForDefinedMethod
net.bytebuddy.dynamic.scaffold.TypeWriter.MethodPool.Record.ForDefinedMethod.OfVisibilityBridge
All Implemented Interfaces:
TypeWriter.MethodPool.Record, ByteCodeAppender
Enclosing class:
TypeWriter.MethodPool.Record.ForDefinedMethod

@Enhance public static class TypeWriter.MethodPool.Record.ForDefinedMethod.OfVisibilityBridge extends TypeWriter.MethodPool.Record.ForDefinedMethod implements ByteCodeAppender
A record for a visibility bridge.
  • Field Details

    • visibilityBridge

      private final MethodDescription visibilityBridge
      The visibility bridge.
    • bridgeTarget

      private final MethodDescription bridgeTarget
      The method the visibility bridge invokes.
    • bridgeType

      private final TypeDescription bridgeType
      The type on which the bridge method is invoked.
    • attributeAppender

      private final MethodAttributeAppender attributeAppender
      The attribute appender to apply to the visibility bridge.
  • Constructor Details

    • OfVisibilityBridge

      protected OfVisibilityBridge(MethodDescription visibilityBridge, MethodDescription bridgeTarget, TypeDescription bridgeType, MethodAttributeAppender attributeAppender)
      Creates a new record for a visibility bridge.
      Parameters:
      visibilityBridge - The visibility bridge.
      bridgeTarget - The method the visibility bridge invokes.
      bridgeType - The type of the instrumented type.
      attributeAppender - The attribute appender to apply to the visibility bridge.
  • Method Details

    • of

      public static TypeWriter.MethodPool.Record of(TypeDescription instrumentedType, MethodDescription bridgeTarget, MethodAttributeAppender attributeAppender)
      Creates a record for a visibility bridge.
      Parameters:
      instrumentedType - The instrumented type.
      bridgeTarget - The target method of the visibility bridge.
      attributeAppender - The attribute appender to apply to the visibility bridge.
      Returns:
      A record describing the visibility bridge.
    • 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.
    • getSort

      Returns the sort of this method instrumentation.
      Specified by:
      getSort in interface TypeWriter.MethodPool.Record
      Returns:
      The sort of this method instrumentation.
    • 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.
    • 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.
    • apply

      public ByteCodeAppender.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod)
      Applies this byte code appender to a type creation process.
      Specified by:
      apply in interface ByteCodeAppender
      Parameters:
      methodVisitor - The method visitor to which the byte code appender writes its code to.
      implementationContext - The implementation context of the current type creation process.
      instrumentedMethod - The method that is the target of the instrumentation.
      Returns:
      The required size for the applied byte code to run.