Package: org.codehaus.groovy.vmplugin.v8

## [Java] Class IndyGuardsFiltersAndSignatures

- org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures

-     public class IndyGuardsFiltersAndSignatures
      extends Object

  This class contains guards, runtime filters and MethodType signatures used by indy.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static MethodHandle` | `NULL_REF` | Constant handle that always returns `null`.
    `protected static MethodHandle` | `SAME_CLASS` | Shared guards, filters, constructors, and invokers used when assembling indy call paths.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Object` | `invokeGroovyObjectInvoker(MissingMethodException e, Object receiver, String name, Object[] args)` GroovyObject.invokeMethod path as fallback.
    `` | `public static boolean` | `isNull(Object o)` Guard to check if the argument is null.
    `` | `public static boolean` | `isSameMetaClass(MetaClass mc, Object receiver)` called by handle
    `` | `public static boolean` | `sameClass(Class<?> c, Object o)` Guard to check if the provided Object has the same class as the provided Class.
    `` | `public static boolean` | `sameClasses(Class<?>[] cs, Object[] os)` Guard to check if the provided objects have the same class as the provided classes.
    `` | `public static boolean` | `sameClasses(Class<?> c0, Class<?> c1, Object o0, Object o1)` Two-argument same-class guard used by hot indy sites so `asCollector(Object[].class, n)` does not allocate an `Object[]` on every invocation.
    `` | `public static boolean` | `sameClasses(Class<?> c0, Class<?> c1, Class<?> c2, Object o0, Object o1, Object o2)` Three-argument same-class guard; see sameClasses(Class, Class, Object, Object).
    `` | `public static boolean` | `sameClasses(Class<?> c0, Class<?> c1, Class<?> c2, Class<?> c3, Object o0, Object o1, Object o2, Object o3)` Four-argument same-class guard; see sameClasses(Class, Class, Object, Object).
    `` | `public static Object` | `setBeanProperties(MetaClass mc, Object bean, Map properties)` This method is called by the handle to realize the bean constructor with property map.
    `` | `public static void` | `setProperty(String name, Class<?> sender, Object receiver, Object value)` Adapter shim for the non-fast-path property write of the indy `SetPropertySelector`.
    `` | `public static Object` | `unwrap(GroovyRuntimeException gre)` Unwraps a GroovyRuntimeException.
    `` | `public static Object` | `unwrap(Object o)` Unwraps a Wrapper.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### protected static final MethodHandle NULL_REF

      Constant handle that always returns `null`.

    - #### protected static final MethodHandle SAME_CLASS

      Shared guards, filters, constructors, and invokers used when assembling indy call paths.

  - ### Method Detail

    - #### public static Object invokeGroovyObjectInvoker(MissingMethodException e, Object receiver, String name, Object[] args)

      GroovyObject.invokeMethod path as fallback. This method is called by the handle as exception handler in case the selected method causes a MissingMethodExecutionFailed, where we will just give through the exception, and a normal MissingMethodException where we call GroovyObject.invokeMethod if receiver class, the type transported by the exception and the name for the method stored in the exception and our current method name are equal. Should those conditions not apply we just rethrow the exception.

    - #### public static boolean isNull(Object o)

      Guard to check if the argument is null. This method is called by the handle to check if the provided argument is null.

    - #### public static boolean isSameMetaClass(MetaClass mc, Object receiver)

      called by handle

    - #### public static boolean sameClass(Class<?> c, Object o)

      Guard to check if the provided Object has the same class as the provided Class. This method will return false if the Object is null.

    - #### public static boolean sameClasses(Class<?>[] cs, Object[] os)

      Guard to check if the provided objects have the same class as the provided classes.

    - #### public static boolean sameClasses(Class<?> c0, Class<?> c1, Object o0, Object o1)

      Two-argument same-class guard used by hot indy sites so `asCollector(Object[].class, n)` does not allocate an `Object[]` on every invocation. `Selector` binds the expected classes with a single MethodHandles.insertArguments call.

    - #### public static boolean sameClasses(Class<?> c0, Class<?> c1, Class<?> c2, Object o0, Object o1, Object o2)

      Three-argument same-class guard; see sameClasses(Class, Class, Object, Object).

    - #### public static boolean sameClasses(Class<?> c0, Class<?> c1, Class<?> c2, Class<?> c3, Object o0, Object o1, Object o2, Object o3)

      Four-argument same-class guard; see sameClasses(Class, Class, Object, Object).

    - #### public static Object setBeanProperties(MetaClass mc, Object bean, Map properties)

      This method is called by the handle to realize the bean constructor with property map.

    - #### public static void setProperty(String name, Class<?> sender, Object receiver, Object value)

      Adapter shim for the non-fast-path property write of the indy `SetPropertySelector`. The parameter order — `name`, `sender`, `receiver`, `value` — is chosen so that binding the compile-time-known `name` and `sender` as a leading prefix with a single MethodHandles.insertArguments call leaves exactly the call-site shape `(receiver, value)void`, with no permute required. For now it just reorders into ScriptBytecodeAdapter.setProperty; this is also the natural seam for inlining that resolution logic in the future.

    - #### public static Object unwrap(GroovyRuntimeException gre)

      Unwraps a GroovyRuntimeException. This method is called by the handle to unwrap internal exceptions of the runtime.

    - #### public static Object unwrap(Object o)

      Unwraps a Wrapper. This method is called by the handle to unwrap a Wrapper, which we use to force method selection.