oracle/graal · error · IllegalArgumentException

Unsupported array: Value: %s, Value type: %s

Error message

Unsupported array: Value: %s, Value type: %s

What it means

IllegalArgumentException from ObjectCopierOutputStream's array-writing method: the value is an array whose component type is not one of the supported primitive components (boolean, byte, char, short, int, long, float, double as handled by the preceding branches, ending at double[]). The message includes the whole array value and its class, so even the failure report identifies the array type.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/ObjectCopierOutputStream.java:201

                internalWritePackedSigned(Array.getInt(value, i));
            }
        } else if (compClz == long.class) {
            internalWriteByte('J');
            for (int i = 0; i < length; i++) {
                internalWritePackedSigned(Array.getLong(value, i));
            }
        } else if (compClz == float.class) {
            internalWriteByte('F');
            for (int i = 0; i < length; i++) {
                out.writeFloat(Array.getFloat(value, i));
            }
        } else if (compClz == double.class) {
            internalWriteByte('D');
            for (int i = 0; i < length; i++) {
                out.writeDouble(Array.getDouble(value, i));
            }
        } else {
            throw new IllegalArgumentException(String.format("Unsupported array: Value: %s, Value type: %s", value, value.getClass()));
        }
        if (debugOut != null) {
            for (int i = 0; i < length; i++) {
                debugPrintValue(Array.get(value, i));
            }
        }
    }

    private static long encodeSign(long value) {
        return (value << 1) ^ (value >> 63);
    }

    protected void internalWritePackedSigned(long value) throws IOException {
        // this is a modified version of the SIGNED5 encoding from Pack200
        writePacked(encodeSign(value));
    }

    public void writePackedUnsignedInt(int value) throws IOException {

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Convert reference arrays before copying: String[] can become a delimited String or be copied element-by-element as scalars; Object[] usually indicates the state is too rich for ObjectCopier.
  2. Restructure the copied state to primitive arrays (int[], double[], ...) plus separate scalar entries.
  3. Use a real serializer for object graphs; ObjectCopier is intentionally minimal for value snapshots.
  4. Note the message prints the full array — avoid copying huge arrays in production paths where the exception text itself would be costly.

Example fix

// before
ObjectCopier.copy(new String[]{"a","b"}, out); // String[] unsupported

// after
ObjectCopier.copy(String.join(",", new String[]{"a","b"}), out); // scalar String
Defensive patterns

Strategy: type-guard

Validate before calling

static boolean isCopierArray(Object v) {
    return v != null && v.getClass().isArray()
        && v.getClass().getComponentType().isPrimitive(); // only primitive arrays
}

// convert reference arrays before copying
static Object toArraySafe(Object v) {
    if (v instanceof String[] arr) return String.join("\u0000", arr);
    return v;
}

Type guard

static boolean isCopierArray(Object v) {
    return v != null && v.getClass().isArray()
        && v.getClass().getComponentType().isPrimitive();
}

Prevention

When it happens

Trigger: Passing an Object[], String[], or an array of any reference component type to the copier's write path — compClz matches none of the primitive component branches and falls to the throw.

Common situations: Trying to copy state containing String[] (e.g. captured argument lists) or Object[] (varargs captures); assuming 'array' support means all arrays when only primitive arrays plus separately-handled scalars are supported.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/84c7b27be6d6510c. Report an issue: GitHub.