Package: org.codehaus.groovy.runtime

## [Java] Class ScriptBytecodeAdapter

- org.codehaus.groovy.runtime.ScriptBytecodeAdapter

-     @GroovyABI(since = "1.0.0")
      public class ScriptBytecodeAdapter
      extends Object

  A static helper class to interface bytecode and runtime

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static Object[]` | `EMPTY_ARGS` | An empty Object array constant.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Object` | `asType(Object object, Class type)` Provides a hook for type coercion of the given object to the required type
    `` | `public static void` | `assertFailed(Object expression, Object message)`
    `` | `public static Object` | `bitwiseNegate(Object value)`
    `` | `public static Object` | `castToType(Object object, Class type)` Provides a hook for type casting of the given object to the required type
    `` | `public static boolean` | `compareEqual(Object left, Object right)`
    `` | `public static boolean` | `compareGreaterThan(Object left, Object right)`
    `` | `public static boolean` | `compareGreaterThanEqual(Object left, Object right)`
    `` | `public static boolean` | `compareIdentical(Object left, Object right)`
    `` | `public static boolean` | `compareLessThan(Object left, Object right)`
    `` | `public static boolean` | `compareLessThanEqual(Object left, Object right)`
    `` | `public static boolean` | `compareNotEqual(Object left, Object right)`
    `` | `public static boolean` | `compareNotIdentical(Object left, Object right)`
    `` | `public static Integer` | `compareTo(Object left, Object right)`
    `` | `public static Object` | `compoundAssign(Object receiver, Object arg, String assignName, String baseName)` GEP-15: dispatcher for compound-assignment operators in dynamic Groovy.
    `` | `public static Wrapper` | `createGroovyObjectWrapper(GroovyObject val, Class clazz)`
    `` | `public static List` | `createList(Object[] values)`
    `` | `public static Map` | `createMap(Object[] values)`
    `` | `public static Wrapper` | `createPojoWrapper(Object val, Class clazz)`
    `` | `public static List` | `createRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight)`
    `` | `public static List` | `createRange(Object from, Object to, boolean inclusive)`
    `` | `public static Tuple` | `createTuple(Object[] array)`
    `` | `public static Object[]` | `despreadList(Object[] args, Object[] spreads, int[] positions)`
    `` | `public static Matcher` | `findRegex(Object left, Object right)`
    `` | `public static Object` | `getField(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getFieldOnSuper(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getFieldOnSuperSafe(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getFieldOnSuperSpreadSafe(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getFieldSafe(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getFieldSpreadSafe(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getGroovyObjectField(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getGroovyObjectFieldSafe(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getGroovyObjectFieldSpreadSafe(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getGroovyObjectProperty(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getGroovyObjectPropertySafe(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getGroovyObjectPropertySpreadSafe(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Closure` | `getMethodPointer(Object object, String methodName)` Returns a method closure for the given object and name.
    `` | `public static Object` | `getProperty(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getPropertyOnSuper(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getPropertyOnSuperSafe(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getPropertyOnSuperSpreadSafe(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `getPropertySafe(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `getPropertySpreadSafe(Class senderClass, Object receiver, String messageName)`
    `` | `public static MetaClass` | `initMetaClass(Object object)`
    `` | `public static Object` | `invokeClosure(Object closure, Object[] arguments)`
    `` | `public static Object` | `invokeMethod0(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `invokeMethod0Safe(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `invokeMethod0SpreadSafe(Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `invokeMethodN(Class senderClass, Object receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodNSafe(Class senderClass, Object receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodNSpreadSafe(Class senderClass, Object receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnCurrent0(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `invokeMethodOnCurrent0Safe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnCurrent0SpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnCurrentNSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnCurrentNSpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnSuper0(Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static Object` | `invokeMethodOnSuper0Safe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnSuper0SpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnSuperN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnSuperNSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeMethodOnSuperNSpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)`
    `` | `public static Object` | `invokeNew0(Class senderClass, Class receiver)`
    `` | `public static Object` | `invokeNewN(Class senderClass, Class receiver, Object arguments)`
    `` | `public static Object` | `invokeStaticMethod0(Class senderClass, Class receiver, String messageName)`
    `` | `public static Object` | `invokeStaticMethodN(Class senderClass, Class receiver, String messageName, Object[] messageArguments)`
    `` | `public static boolean` | `isCase(Object switchValue, Object caseExpression)`
    `` | `public static boolean` | `isIn(Object switchValue, Object caseExpression)`
    `` | `public static boolean` | `isNotCase(Object switchValue, Object caseExpression)`
    `` | `public static boolean` | `isNotIn(Object switchValue, Object caseExpression)`
    `` | `public static boolean` | `matchRegex(Object left, Object right)`
    `` | `public static Closure<?>` | `packedClosure(Object owner, Object dispatchers, int id, String method, Object[] captured, Class[] paramTypes, boolean strict, boolean implicit, boolean vararg)` GROOVY-12151: the bytecode-facing factory for the shared packed-closure adapter.
    `` | `public static Pattern` | `regexPattern(Object regex)`
    `` | `public static int` | `selectConstructorAndTransformArguments(Object[] arguments, int numberOfConstructors, Class which)`
    `` | `public static void` | `setField(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setFieldOnSuper(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setFieldOnSuperSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setFieldOnSuperSpreadSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setFieldSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setFieldSpreadSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setGroovyObjectField(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setGroovyObjectFieldSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setGroovyObjectFieldSpreadSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setGroovyObjectProperty(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setGroovyObjectPropertySafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setGroovyObjectPropertySpreadSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setProperty(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setPropertyOnSuper(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setPropertyOnSuperSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setPropertyOnSuperSpreadSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)`
    `` | `public static void` | `setPropertySafe(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static void` | `setPropertySpreadSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)`
    `` | `public static Object` | `spreadMap(Object value)`
    `` | `public static Object` | `unaryMinus(Object value)`
    `` | `public static Object` | `unaryPlus(Object value)`
    `` | `public static Throwable` | `unwrap(GroovyRuntimeException gre)` Unwraps a GroovyRuntimeException, extracting the actual cause if present.

  - ### Inherited Methods Summary

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

- - ### Field Detail

    - #### public static final Object[] EMPTY_ARGS

      An empty Object array constant.

  - ### Method Detail

    - #### public static Object asType(Object object, Class type)

      Provides a hook for type coercion of the given object to the required type

      throws:
        Throwable if the coercion fails
      Parameters:
        `type` - of object to convert the given object to
        `object` - the object to be converted
      Returns:
        the original object or a new converted value

    - #### public static void assertFailed(Object expression, Object message)

    - #### public static Object bitwiseNegate(Object value)

    - #### public static Object castToType(Object object, Class type)

      Provides a hook for type casting of the given object to the required type

      throws:
        Throwable if the type casting fails
      Parameters:
        `type` - of object to convert the given object to
        `object` - the object to be converted
      Returns:
        the original object or a new converted value

    - #### public static boolean compareEqual(Object left, Object right)

    - #### public static boolean compareGreaterThan(Object left, Object right)

    - #### public static boolean compareGreaterThanEqual(Object left, Object right)

    - #### public static boolean compareIdentical(Object left, Object right)

    - #### public static boolean compareLessThan(Object left, Object right)

    - #### public static boolean compareLessThanEqual(Object left, Object right)

    - #### public static boolean compareNotEqual(Object left, Object right)

    - #### public static boolean compareNotIdentical(Object left, Object right)

    - #### public static Integer compareTo(Object left, Object right)

    - #### @GroovyABI(since = "6.0.0")
      public static Object compoundAssign(Object receiver, Object arg, String assignName, String baseName)

      GEP-15: dispatcher for compound-assignment operators in dynamic Groovy. If `receiver` responds to `assignName` with the supplied argument, invoke it and return `receiver` (so the caller's STORE assigns the same reference back, leaving the in-place mutation visible). Otherwise fall back to `baseName` and return its result for the caller to assign.

      Since:
        6.0.0

    - #### public static Wrapper createGroovyObjectWrapper(GroovyObject val, Class clazz)

    - #### public static List createList(Object[] values)

    - #### public static Map createMap(Object[] values)

    - #### public static Wrapper createPojoWrapper(Object val, Class clazz)

    - #### @GroovyABI(since = "4.0.0")
      public static List createRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight)

    - #### public static List createRange(Object from, Object to, boolean inclusive)

    - #### public static Tuple createTuple(Object[] array)

    - #### public static Object[] despreadList(Object[] args, Object[] spreads, int[] positions)

    - #### public static Matcher findRegex(Object left, Object right)

    - #### public static Object getField(Class senderClass, Object receiver, String messageName)

    - #### public static Object getFieldOnSuper(Class senderClass, Object receiver, String messageName)

    - #### public static Object getFieldOnSuperSafe(Class senderClass, Object receiver, String messageName)

    - #### public static Object getFieldOnSuperSpreadSafe(Class senderClass, Object receiver, String messageName)

    - #### public static Object getFieldSafe(Class senderClass, Object receiver, String messageName)

    - #### public static Object getFieldSpreadSafe(Class senderClass, Object receiver, String messageName)

    - #### public static Object getGroovyObjectField(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getGroovyObjectFieldSafe(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getGroovyObjectFieldSpreadSafe(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getGroovyObjectProperty(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getGroovyObjectPropertySafe(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getGroovyObjectPropertySpreadSafe(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Closure getMethodPointer(Object object, String methodName)

      Returns a method closure for the given object and name.

      Parameters:
        `object` - the object or class providing the method
        `methodName` - the method(s) of interest
      Returns:
        the resulting Closure

    - #### public static Object getProperty(Class senderClass, Object receiver, String messageName)

    - #### public static Object getPropertyOnSuper(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getPropertyOnSuperSafe(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getPropertyOnSuperSpreadSafe(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object getPropertySafe(Class senderClass, Object receiver, String messageName)

    - #### public static Object getPropertySpreadSafe(Class senderClass, Object receiver, String messageName)

    - #### public static MetaClass initMetaClass(Object object)

    - #### public static Object invokeClosure(Object closure, Object[] arguments)

    - #### public static Object invokeMethod0(Class senderClass, Object receiver, String messageName)

    - #### public static Object invokeMethod0Safe(Class senderClass, Object receiver, String messageName)

    - #### public static Object invokeMethod0SpreadSafe(Class senderClass, Object receiver, String messageName)

    - #### public static Object invokeMethodN(Class senderClass, Object receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodNSafe(Class senderClass, Object receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodNSpreadSafe(Class senderClass, Object receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnCurrent0(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object invokeMethodOnCurrent0Safe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnCurrent0SpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnCurrentNSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnCurrentNSpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnSuper0(Class senderClass, GroovyObject receiver, String messageName)

    - #### public static Object invokeMethodOnSuper0Safe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnSuper0SpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnSuperN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnSuperNSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeMethodOnSuperNSpreadSafe(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)

    - #### public static Object invokeNew0(Class senderClass, Class receiver)

    - #### public static Object invokeNewN(Class senderClass, Class receiver, Object arguments)

    - #### public static Object invokeStaticMethod0(Class senderClass, Class receiver, String messageName)

    - #### public static Object invokeStaticMethodN(Class senderClass, Class receiver, String messageName, Object[] messageArguments)

    - #### public static boolean isCase(Object switchValue, Object caseExpression)

    - #### public static boolean isIn(Object switchValue, Object caseExpression)

    - #### public static boolean isNotCase(Object switchValue, Object caseExpression)

    - #### public static boolean isNotIn(Object switchValue, Object caseExpression)

    - #### public static boolean matchRegex(Object left, Object right)

    - #### @GroovyABI(since = "6.0.0")
      public static Closure<?> packedClosure(Object owner, Object dispatchers, int id, String method, Object[] captured, Class[] paramTypes, boolean strict, boolean implicit, boolean vararg)

      GROOVY-12151: the bytecode-facing factory for the shared packed-closure adapter. The compiler emits one `INVOKESTATIC` of this method per packed closure literal; hosting the factory here (with the dispatcher bundle travelling as `Object` and the result as `Closure`) keeps `PackedClosure` and `GeneratedDispatcher.Bundle` off the emitted-bytecode surface entirely. The cast is negligible against the object-creation cost.

      Parameters:
        `owner` - the enclosing instance (or the enclosing `Class` in a static context)
        `dispatchers` - the hosting class's linked GeneratedDispatcher.Bundle
        `id` - the hoisted body's compile-time id in the class's dispatch tables
        `method` - the hoisted method's name (diagnostics only)
        `captured` - captured values (`Reference`s for written captures), or `null`
        `paramTypes` - the literal's declared parameter types
        `strict` - whether the adapter installs the fail-fast delegate guard (dynamic trust path)
        `implicit` - whether the literal has an implicit `it` parameter (fuzzy 0/1 arity)
        `vararg` - whether the literal's last parameter is a trailing array (varargs selection)
      Returns:
        the packed closure adapter
      Since:
        6.0.0

    - #### public static Pattern regexPattern(Object regex)

    - #### public static int selectConstructorAndTransformArguments(Object[] arguments, int numberOfConstructors, Class which)

    - #### public static void setField(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setFieldOnSuper(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setFieldOnSuperSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setFieldOnSuperSpreadSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setFieldSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setFieldSpreadSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setGroovyObjectField(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setGroovyObjectFieldSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setGroovyObjectFieldSpreadSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setGroovyObjectProperty(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setGroovyObjectPropertySafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setGroovyObjectPropertySpreadSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setProperty(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setPropertyOnSuper(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setPropertyOnSuperSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setPropertyOnSuperSpreadSafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)

    - #### public static void setPropertySafe(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static void setPropertySpreadSafe(Object messageArgument, Class senderClass, Object receiver, String messageName)

    - #### public static Object spreadMap(Object value)

    - #### public static Object unaryMinus(Object value)

    - #### public static Object unaryPlus(Object value)

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

      Unwraps a GroovyRuntimeException, extracting the actual cause if present. Converts GroovyRuntimeException instances that wrap actual exceptions to those exceptions.

      Parameters:
        `gre` - the GroovyRuntimeException to unwrap
      Returns:
        the unwrapped Throwable