Class InvokerFactory

java.lang.Object
org.apache.groovy.internal.runtime.invoke.InvokerFactory

public final class InvokerFactory extends Object
Factory for DirectInvoker instances bound to one CachedMethod.

Not user API. CachedMethod.invoke is the only production caller. Package-visible helpers exist so tests can drive generation without going through the hit-count hook.

Define path (one order):

  1. InvokerFactory nestmate + INVOKE* when the member is publicly invocable from this class and every type is resolvable here (String.startsWith).
  2. Declaring-class nestmate + INVOKE* when privateLookupIn is worth attempting and the host can resolve DirectInvoker.
  3. InvokerFactory nestmate + classData MethodHandle when this loader can resolve the erased invokeExact types.
  4. ClassLoaderForClassArtifacts visible class, only when that loader can resolve DirectInvoker — never for bootstrap hosts.
Failures sticky-return null; they must not propagate to CachedMethod.invoke.
Since:
6.0.0
  • Field Details

    • PROPERTY_THRESHOLD

      public static final String PROPERTY_THRESHOLD
      Hits before generation. Default DEFAULT_THRESHOLD — the same order as groovy.indy.optimize.threshold, so a method that stays on doMethodInvoke long enough to look hot also qualifies for a trampoline.
      See Also:
    • DEFAULT_THRESHOLD

      public static final long DEFAULT_THRESHOLD
      Default for PROPERTY_THRESHOLD.
      See Also:
    • PROPERTY_DISABLE

      public static final String PROPERTY_DISABLE
      Kill switch. Default false.
      See Also:
  • Method Details

    • tryCreate

      public static DirectInvoker tryCreate(CachedMethod method)
      Attempts to bind a trampoline for method. Returns null on any failure (sticky-fail). Public so CachedMethod in another package can call it; not user API (Internal, internal package). Tests in this package also drive generation through this method without going through the hit-count hook.
      Parameters:
      method - the cached method to bind
      Returns:
      a trampoline, or null
    • generationAllowed

      public static boolean generationAllowed()
      Package-visible predicate. Android cannot be flipped with a property (AndroidSupport.isRunningAndroid() is Class.forName( "android.app.Activity") captured at class-init). Native image is HiddenClassDefiner.isEnabled() — do not also gate on AotDispatch.isAotLinkRequested(), which is true on HotSpot when -Dgroovy.indy.aot.link=true and would silently disable generation in AOT-dispatch unit tests.
      Returns:
      true when generation may be attempted