Package org.codehaus.groovy.classgen.asm.sc

# Interface AbstractFunctionalInterfaceWriter

All Known Implementing Classes:
  `StaticTypesLambdaWriter`, `StaticTypesMethodReferenceExpressionWriter`

public interface AbstractFunctionalInterfaceWriter
Shared bytecode and deserialization support for statically-compiled functional interface implementations, including both lambdas and method references.

Since:
  3.0.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static final record`
  `AbstractFunctionalInterfaceWriter.SerializedLambdaFingerprint`
  Compile-time identity of one serialized functional-interface target used by `$deserializeLambda$` dispatch.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `addDeserializeDispatcherEntry(WriterController controller, Parameter[] deserializeMethodParameters, AbstractFunctionalInterfaceWriter.SerializedLambdaFingerprint serializedLambdaFingerprint, MethodNode helperMethod)`
  Registers a deserialization guard that routes a serialized lambda back to its helper method.
  `default ClassNode`
  `convertParameterType(ClassNode targetType, ClassNode parameterType, ClassNode inferredType)`
  Reconciles the inferred lambda parameter type with the target functional-interface parameter type.
  `default Parameter`
  `createCapturedReceiverParameter(ClassNode receiverType, String parameterName)`
  Creates the synthetic parameter that carries a captured receiver into a generated lambda factory.
  `default Parameter[]`
  `createDeserializeMethodParameters()`
  Creates the parameter list for a synthetic `$deserializeLambda$` helper.
  `default String`
  `createFunctionalInterfaceFactoryDescriptor(ClassNode functionalType, Parameter[] capturedParameters)`
  Returns the invoked type descriptor used to create the functional-interface instance.
  `default String`
  `createMethodDescriptor(ClassNode returnType, Parameter[] parameters)`
  Returns the JVM method descriptor for the supplied return type and parameters.
  `default String`
  `createMethodDescriptor(MethodNode method)`
  Returns the JVM method descriptor for the supplied method node.
  `default AbstractFunctionalInterfaceWriter.SerializedLambdaFingerprint`
  `createSerializedLambdaFingerprint(String samMethodDescriptor, ClassNode capturingClass, int implMethodKind, ClassNode implClassNode, MethodNode implMethodNode, Parameter[] implMethodParameters, ClassNode functionalType, MethodNode abstractMethod, int capturedArgumentCount)`
  Builds the serialized-lambda fingerprint used to dispatch deserialization helpers.
  `default void`
  `writeFunctionalInterfaceIndy(org.objectweb.asm.MethodVisitor methodVisitor, String samMethodName, String invokedTypeDescriptor, String samMethodDescriptor, int implMethodKind, ClassNode implClassNode, MethodNode implMethodNode, Parameter[] implMethodParameters, boolean serializable)`
  Emits the bootstrap invocation for a functional-interface implementation without additional marker interfaces.
  `default void`
  `writeFunctionalInterfaceIndy(org.objectweb.asm.MethodVisitor methodVisitor, String samMethodName, String invokedTypeDescriptor, String samMethodDescriptor, int implMethodKind, ClassNode implClassNode, MethodNode implMethodNode, Parameter[] implMethodParameters, boolean serializable, ClassNode[] markers)`
  Marker-aware variant for intersection-cast targets such as `(Runnable & Cloneable) () -> ...`.

- ## Method Details

  - ### writeFunctionalInterfaceIndy

    default void writeFunctionalInterfaceIndy(org.objectweb.asm.MethodVisitor methodVisitor, String samMethodName, String invokedTypeDescriptor, String samMethodDescriptor, int implMethodKind, ClassNode implClassNode, MethodNode implMethodNode, Parameter[] implMethodParameters, boolean serializable)
    Emits the bootstrap invocation for a functional-interface implementation without additional marker interfaces.

  - ### writeFunctionalInterfaceIndy

    default void writeFunctionalInterfaceIndy(org.objectweb.asm.MethodVisitor methodVisitor, String samMethodName, String invokedTypeDescriptor, String samMethodDescriptor, int implMethodKind, ClassNode implClassNode, MethodNode implMethodNode, Parameter[] implMethodParameters, boolean serializable, ClassNode[] markers)
    Marker-aware variant for intersection-cast targets such as `(Runnable & Cloneable) () -> ...`. Markers are threaded through `LambdaMetafactory.altMetafactory` via `FLAG_MARKERS` so the generated lambda implements every component interface at runtime.
    Since:
      6.0.0

  - ### createMethodDescriptor

    default String createMethodDescriptor(MethodNode method)
    Returns the JVM method descriptor for the supplied method node.

  - ### createMethodDescriptor

    default String createMethodDescriptor(ClassNode returnType, Parameter[] parameters)
    Returns the JVM method descriptor for the supplied return type and parameters.

  - ### createFunctionalInterfaceFactoryDescriptor

    default String createFunctionalInterfaceFactoryDescriptor(ClassNode functionalType, Parameter[] capturedParameters)
    Returns the invoked type descriptor used to create the functional-interface instance.

  - ### createCapturedReceiverParameter

    default Parameter createCapturedReceiverParameter(ClassNode receiverType, String parameterName)
    Creates the synthetic parameter that carries a captured receiver into a generated lambda factory.

  - ### convertParameterType

    default ClassNode convertParameterType(ClassNode targetType, ClassNode parameterType, ClassNode inferredType)
    Reconciles the inferred lambda parameter type with the target functional-interface parameter type.

  - ### createSerializedLambdaFingerprint

    default AbstractFunctionalInterfaceWriter.SerializedLambdaFingerprint createSerializedLambdaFingerprint(String samMethodDescriptor, ClassNode capturingClass, int implMethodKind, ClassNode implClassNode, MethodNode implMethodNode, Parameter[] implMethodParameters, ClassNode functionalType, MethodNode abstractMethod, int capturedArgumentCount)
    Builds the serialized-lambda fingerprint used to dispatch deserialization helpers.

  - ### addDeserializeDispatcherEntry

    default void addDeserializeDispatcherEntry(WriterController controller, Parameter[] deserializeMethodParameters, AbstractFunctionalInterfaceWriter.SerializedLambdaFingerprint serializedLambdaFingerprint, MethodNode helperMethod)
    Registers a deserialization guard that routes a serialized lambda back to its helper method.

  - ### createDeserializeMethodParameters

    default Parameter[] createDeserializeMethodParameters()
    Creates the parameter list for a synthetic `$deserializeLambda$` helper.