Class PackedClosure.FixedN

All Implemented Interfaces:
GroovyCallable<Object>, GroovyObject, Serializable, Cloneable, Runnable, Callable<Object>, GeneratedClosure
Enclosing class:
PackedClosure

public static final class PackedClosure.FixedN extends PackedClosure implements GeneratedClosure
Arities above four (rare) and vararg-shaped literals (trailing array parameter, e.g. { ...z -> }, any arity): a varargs doCall — MOP selection packs the arguments back into one array, and PackedClosure.dispatchAll(java.lang.Object[]) applies the same arity/coercion contract as the base call lanes. For the vararg shapes this varargs declaration is also the faithful one: their generated class declares a vararg doCall, whose selection flexibility (zero arguments collect to an empty trailing array where a fixed one-parameter doCall would null-fill) a Fixed* member cannot reproduce. A single Object[] argument spreads through MOP routes here, exactly as it feeds the trailing array of a classed vararg doCall.
See Also:
  • Constructor Details

    • FixedN

      public FixedN(Object owner, GeneratedDispatcher.Bundle dispatchers, int id, String method, Object[] captured, Class[] visibleTypes, boolean strict)
      Initializes the packed closure used for five or more parameters and for a trailing array parameter. doCall(Object...) forwards its array to PackedClosure.dispatchAll(java.lang.Object[]).

      The arguments are forwarded to PackedClosure. owner is stored as the closure owner, the delegate, and the this object, and as the receiver each later dispatch passes to the hoisted method. The general, one-value, and two-value dispatchers are taken from dispatchers. id and method are stored. captured is kept by reference, and a null array is replaced with an empty one. Closure first fills the parameter metadata by reflecting this member's doCall; that metadata is then replaced by visibleTypes, which is also kept by reference.

      Parameters:
      owner - the object stored as the closure owner, the delegate, and the this object, and as the receiver passed to the hoisted method. A static hoisted method is given the enclosing class
      dispatchers - the hosting class's GeneratedDispatcher tables. The general, one-value, and two-value dispatchers are read from this bundle
      id - index of the hoisted method in those tables
      method - name of the hoisted method, kept for diagnostics
      captured - values closed over from the enclosing scope and passed ahead of the call arguments. null is stored as an empty array; a non-null array is retained by reference
      visibleTypes - declared parameter types, retained by reference and installed as this closure's parameter metadata in place of the types reflected from doCall
      strict - value stored for the delegate and resolve-strategy guards. true makes a non-null delegate other than the owner, or a strategy other than owner-first or owner-only, fail when it is set
  • Method Details

    • doCall

      public Object doCall(Object... args)
      Forwards the varargs array to the hoisted method.

      A null array is treated as no arguments. A caller that passes one Object[] supplies that array as args, so its elements are the call arguments. An exact stored parameter count coerces each value and dispatches. When the argument list holds one List and the stored count is not one, that list is spread. A trailing array parameter collects extra arguments, and a call one argument short of that signature supplies an empty array for it. A non-array one-parameter call with no arguments binds null. An argument list that still does not fit, or a value that cannot be coerced, raises MissingMethodException. An exception thrown by the hoisted method propagates to the caller.

      Parameters:
      args - call arguments already packed into one array. null means none
      Returns:
      the value returned by the hoisted method, or null when that method is void