quarkusio/quarkus · error · java.lang.IllegalArgumentException

Not an array type ${type}

Error message

Not an array type ${type}

What it means

Types.getArrayComponentType() returns the component type of an array Type. If the given type is not a Class that isArray() (e.g. a parameterized type, type variable, or plain class), it throws this IllegalArgumentException. It is a strict precondition helper: callers must pass actual array types.

Source

Thrown at independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Types.java:94

    }

    /**
     * Determines the component type for a given array type.
     *
     * @param type the given array type
     * @return the component type of a given array type
     */
    public static Type getArrayComponentType(Type type) {
        if (type instanceof GenericArrayType) {
            return GenericArrayType.class.cast(type).getGenericComponentType();
        }
        if (type instanceof Class<?>) {
            Class<?> clazz = (Class<?>) type;
            if (clazz.isArray()) {
                return clazz.getComponentType();
            }
        }
        throw new IllegalArgumentException("Not an array type " + type);
    }

    /**
     * Determines whether the given array only contains unbounded type variables or Object.class.
     *
     * @param types the given array of types
     * @return true if and only if the given array only contains unbounded type variables or Object.class
     */
    static boolean isArrayOfUnboundedTypeVariablesOrObjects(Type[] types) {
        for (Type type : types) {
            if (Object.class.equals(type)) {
                continue;
            }
            if (type instanceof TypeVariable<?>) {
                Type[] bounds = ((TypeVariable<?>) type).getBounds();
                if (bounds == null || bounds.length == 0 || (bounds.length == 1 && Object.class.equals(bounds[0]))) {
                    continue;
                }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check type instanceof Class && ((Class<?>) type).isArray() before calling, or handle GenericArrayType explicitly
  2. Use Types.getTypeName/other helpers to inspect the type first
  3. Unwrap wrapper types (ParameterizedType raw type, wildcard bounds) to reach the actual array Class

Example fix

// before
Class<?> comp = Types.getArrayComponentType(genericArrayType);
// after
Class<?> comp = type instanceof GenericArrayType
    ? (Class<?>) ((GenericArrayType) type).getGenericComponentType()
    : Types.getArrayComponentType(type);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(type instanceof Class<?> c) || !c.isArray()) throw new IllegalArgumentException("Expected array type: " + type);

Type guard

static boolean isArrayType(Type t) { return (t instanceof Class<?> c && c.isArray()) || t instanceof GenericArrayType; }

Try / catch

try { return Types.getArrayComponentType(type); }
catch (IllegalArgumentException e) { throw new IllegalArgumentException("Not an array: " + type, e); }

Prevention

When it happens

Trigger: Calling Types.getArrayComponentType(type) with a non-array type — a scalar Class, ParameterizedType, GenericArrayType handled elsewhere, WildcardType, or TypeVariable.

Common situations: Extension code resolving bean types from raw metadata without first checking isArray(); handling GenericArrayType (e.g. List<String>[]) which is not a plain Class; accidental pass-through of field/method generic types.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/b1f3c1b4fba99004. Report an issue: GitHub.