Class ELArray

java.lang.Object
io.micronaut.el.runtime.ELArray

@Internal public final class ELArray extends Object
Direct operations on Java arrays.

The Jakarta EL array resolver uses java.lang.reflect.Array for all array element access. These operations are kept in typed branches so interpreted expressions do not pay that reflective invocation cost.

Since:
1.1
Author:
Denis Stepanov
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable Object
    get(Object array, int index)
    Reads an array element using a typed JVM array operation.
    static boolean
    isArray(Object value)
    Returns whether the value is a Java array.
    static int
    length(Object value)
    Returns the array length, or -1 when the value is not an array.
    static Object
    newInstance(Class<?> componentType, int length)
    Creates an array of the given component type, without java.lang.reflect.Array.
    static void
    set(Object array, int index, @Nullable Object value)
    Writes an array element using a typed JVM array operation.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isArray

      public static boolean isArray(Object value)
      Returns whether the value is a Java array.
      Parameters:
      value - The value
      Returns:
      Whether the value is a Java array
    • length

      public static int length(Object value)
      Returns the array length, or -1 when the value is not an array.
      Parameters:
      value - The value
      Returns:
      The array length, or -1 when the value is not an array
    • newInstance

      public static Object newInstance(Class<?> componentType, int length)
      Creates an array of the given component type, without java.lang.reflect.Array.

      A primitive component type reaches the JVM array creation of that type directly. A reference one goes through Arrays.copyOf(Object[], int, Class), which builds the array of the requested type and leaves its elements null.

      Parameters:
      componentType - The component type
      length - The length
      Returns:
      The array
    • get

      public static @Nullable Object get(Object array, int index)
      Reads an array element using a typed JVM array operation.
      Parameters:
      array - The array
      index - The index
      Returns:
      The element, boxed when the array has a primitive component type
    • set

      public static void set(Object array, int index, @Nullable Object value)
      Writes an array element using a typed JVM array operation.

      The primitive branches accept the same widening primitive conversions as Array while reference arrays retain the JVM array-store check.

      Parameters:
      array - The array
      index - The index
      value - The value