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

# Class StaticInvocationWriter

java.lang.Object
org.codehaus.groovy.classgen.asm.InvocationWriter
org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter

public class StaticInvocationWriter extends InvocationWriter
Invocation writer for statically compiled code paths.

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.classgen.asm.InvocationWriter

  `castToVargsArray, controller, currentCall, invokeClosureMethod, invokeMethod, invokeMethodOnCurrent, invokeMethodOnSuper, invokeStaticMethod`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StaticInvocationWriter(WriterController wc)`
  Creates an invocation writer that favors direct bytecode calls over dynamic dispatch.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected static boolean`
  `isPrivateBridgeMethodsCallAllowed(ClassNode receiver, ClassNode caller)`
  Deprecated.
  Use bridge metadata on the declaring class instead of probing outer-class nesting manually.
  `protected void`
  `loadArguments(List<Expression> argumentList, Parameter[] parameters)`
  Evaluates and loads each argument expression, handling varargs packing.
  `protected boolean`
  `makeCachedCall(Expression origin, ClassExpression sender, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis, boolean containsSpreadExpression)`
  Attempts to emit a call-site-cached invocation (or invokedynamic).
  `void`
  `makeCall(Expression origin, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis)`
  Generates bytecode for a method call.
  `protected boolean`
  `tryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args)`
  Deprecated.
  `protected boolean`
  `tryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args, ClassNode thisClass)`
  Attempts to make a direct method call on a bridge method, if it exists.
  `protected boolean`
  `writeDirectMethodCall(MethodNode target, boolean implicitThis, Expression receiver, TupleExpression args)`
  Emits a direct (INVOKE*) bytecode call to `target` when static type information is available.
  `void`
  `writeInvokeConstructor(ConstructorCallExpression call)`
  Generates bytecode for a constructor call expression, choosing the appropriate strategy (direct, AIC, or normal call-site).
  `void`
  `writeSpecialConstructorCall(ConstructorCallExpression call)`
  Generates bytecode for a `this()` or `super()` constructor call at the start of a constructor body.

  ### Methods inherited from class org.codehaus.groovy.classgen.asm.InvocationWriter

  `castNonPrimitiveToBool, castToNonPrimitiveIfNecessary, coerce, finnishConstructorCall, getMethodName, makeArgumentList, makeCall, makeClassForNameCall, makeDirectCall, makeSingleArgumentCall, makeSingleArgumentCall, makeUncachedCall, prepareConstructorCall, writeAICCall, writeInvokeMethod, writeInvokeStaticMethod, writeNormalConstructorCall`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### StaticInvocationWriter

    public StaticInvocationWriter(WriterController wc)
    Creates an invocation writer that favors direct bytecode calls over dynamic dispatch.

- ## Method Details

  - ### writeInvokeConstructor

    public void writeInvokeConstructor(ConstructorCallExpression call)
    Generates bytecode for a constructor call expression, choosing the appropriate strategy (direct, AIC, or normal call-site).
    Overrides:
      `writeInvokeConstructor` in class `InvocationWriter`
    Parameters:
      `call` - the constructor call expression to compile

  - ### writeSpecialConstructorCall

    public void writeSpecialConstructorCall(ConstructorCallExpression call)
    Generates bytecode for a `this()` or `super()` constructor call at the start of a constructor body.
    Overrides:
      `writeSpecialConstructorCall` in class `InvocationWriter`
    Parameters:
      `call` - the constructor call expression representing `this()` or `super()`

  - ### tryBridgeMethod

    @Deprecated protected boolean tryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args)
    Deprecated.
    Attempts to make a direct method call on a bridge method, if it exists.

  - ### tryBridgeMethod

    protected boolean tryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args, ClassNode thisClass)
    Attempts to make a direct method call on a bridge method, if it exists.

  - ### writeDirectMethodCall

    protected boolean writeDirectMethodCall(MethodNode target, boolean implicitThis, Expression receiver, TupleExpression args)
    Emits a direct (INVOKE*) bytecode call to `target` when static type information is available. Returns `false` if a direct call cannot be made.
    Overrides:
      `writeDirectMethodCall` in class `InvocationWriter`
    Parameters:
      `target` - the resolved method node to call directly
      `implicitThis` - whether the receiver is implicit `this`
      `receiver` - the receiver expression (may be `null`)
      `args` - the argument tuple
    Returns:
      `true` if the call was emitted, `false` otherwise

  - ### isPrivateBridgeMethodsCallAllowed

    @Deprecated(since="6.0.0") protected static boolean isPrivateBridgeMethodsCallAllowed(ClassNode receiver, ClassNode caller)
    Deprecated.
    Use bridge metadata on the declaring class instead of probing outer-class nesting manually.

  - ### loadArguments

    protected void loadArguments(List<Expression> argumentList, Parameter[] parameters)
    Evaluates and loads each argument expression, handling varargs packing.
    Overrides:
      `loadArguments` in class `InvocationWriter`
    Parameters:
      `argumentList` - the argument expressions to evaluate
      `parameters` - the declared parameters of the target method

  - ### makeCachedCall

    protected boolean makeCachedCall(Expression origin, ClassExpression sender, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis, boolean containsSpreadExpression)
    Attempts to emit a call-site-cached invocation (or invokedynamic). Returns `false` if the call cannot be cached, causing the caller to fall through to the uncached path.
    Overrides:
      `makeCachedCall` in class `InvocationWriter`
    Parameters:
      `origin` - the original call expression
      `sender` - the class from which the call is dispatched
      `receiver` - the receiver expression
      `message` - the method name expression
      `arguments` - the arguments expression
      `adapter` - the method caller adapter
      `safe` - whether to use safe navigation
      `spreadSafe` - whether to use spread-safe navigation
      `implicitThis` - whether the receiver is implicit `this`
      `containsSpreadExpression` - whether any argument uses spread
    Returns:
      `true` if a cached call was emitted

  - ### makeCall

    public void makeCall(Expression origin, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis)
    Generates bytecode for a method call.
    Overrides:
      `makeCall` in class `InvocationWriter`
    Parameters:
      `origin` - the original expression
      `receiver` - the receiver expression
      `message` - the method name expression
      `arguments` - the arguments expression
      `adapter` - the method caller adapter
      `safe` - whether to use safe navigation
      `spreadSafe` - whether to use spread-safe navigation
      `implicitThis` - whether the receiver is implicit 'this'