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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA method representing an accessor bridge method.protected static classA method representing a bridge's target method in its defined shape.Nested classes/interfaces inherited from interface TypeWriter.MethodPool.Record
TypeWriter.MethodPool.Record.AccessBridgeWrapper, TypeWriter.MethodPool.Record.ForDefinedMethod, TypeWriter.MethodPool.Record.ForNonImplementedMethod, TypeWriter.MethodPool.Record.Sort -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MethodAttributeAppenderThe attribute appender being applied for the bridge target.private final MethodDescriptionThe target of the bridge method.private final Set<MethodDescription.TypeToken> A collection of all tokens representing all bridge methods.private final TypeWriter.MethodPool.RecordThe delegate for implementing the bridge's target.private final TypeDescriptionThe instrumented type that defines the bridge methods and the bridge target. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAccessBridgeWrapper(TypeWriter.MethodPool.Record delegate, TypeDescription instrumentedType, MethodDescription bridgeTarget, Set<MethodDescription.TypeToken> bridgeTypes, MethodAttributeAppender attributeAppender) Creates a wrapper for adding accessor bridges. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, AnnotationValueFilter.Factory annotationValueFilterFactory) Applies this method entry.voidapplyAttributes(org.objectweb.asm.MethodVisitor methodVisitor, AnnotationValueFilter.Factory annotationValueFilterFactory) Applies the attributes of this entry.voidapplyBody(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, AnnotationValueFilter.Factory annotationValueFilterFactory) Applies the body of this entry.applyCode(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext) Applies the code of this entry.voidapplyHead(org.objectweb.asm.MethodVisitor methodVisitor) Applies the head of this entry.Returns the method that is implemented where the returned method resembles a potential transformation.getSort()Returns the sort of this method instrumentation.The visibility to enforce for this method.static TypeWriter.MethodPool.Recordof(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.prepend(ByteCodeAppender byteCodeAppender) Prepends the given method appender to this entry.
-
Field Details
-
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.
-
-
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:
getSortin interfaceTypeWriter.MethodPool.Record- Returns:
- The sort of this method instrumentation.
-
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 notTypeWriter.MethodPool.Record.Sort.SKIPPED.- Specified by:
getMethodin interfaceTypeWriter.MethodPool.Record- Returns:
- The implemented method.
-
getVisibility
The visibility to enforce for this method.- Specified by:
getVisibilityin interfaceTypeWriter.MethodPool.Record- Returns:
- The visibility to enforce for this method.
-
prepend
Prepends the given method appender to this entry.- Specified by:
prependin interfaceTypeWriter.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:
applyin interfaceTypeWriter.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 notTypeWriter.MethodPool.Record.Sort.SKIPPED.- Specified by:
applyHeadin interfaceTypeWriter.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 isTypeWriter.MethodPool.Record.Sort.IMPLEMENTED.- Specified by:
applyBodyin interfaceTypeWriter.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 isTypeWriter.MethodPool.Record.Sort.DEFINED.- Specified by:
applyAttributesin interfaceTypeWriter.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 isTypeWriter.MethodPool.Record.Sort.IMPLEMENTED.- Specified by:
applyCodein interfaceTypeWriter.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.
-