oracle/graal · error · IllegalArgumentException

Invalid input range:

Error message

Invalid input range: 

What it means

Error "Invalid input range: " thrown in oracle/graal.

Source

Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java:1056

     * match hosted unaligned read semantics.
     */
    @Override
    public JavaConstant readPrimitiveArrayUnaligned(JavaConstant array, JavaKind kind, int offset) {
        if (kind == null || !kind.isPrimitive() || kind == JavaKind.Void) {
            throw new IllegalArgumentException("Expected a non-void primitive kind, got " + kind);
        }
        if (!(array instanceof EspressoExternalObjectConstant objectConstant)) {
            throw new IllegalArgumentException("Expected an EspressoExternalObjectConstant, got " + safeGetClass(array));
        }
        EspressoResolvedObjectType arrayType = objectConstant.getType();
        if (!(arrayType.isArray() && arrayType.getComponentType().isPrimitive())) {
            throw new IllegalArgumentException("Source should be a primitive array, got " + arrayType);
        }
        Value value = objectConstant.getValue();
        long byteLength = value.getBufferSize();
        int bytesToRead = kind.getByteCount();
        if (offset < 0 || (long) offset + bytesToRead > byteLength) {
            throw new IllegalArgumentException("Invalid input range: " + offset + ".." + (offset + bytesToRead) + " for buffer size " + byteLength);
        }
        return switch (kind) {
            case Boolean -> JavaConstant.forBoolean(value.readBufferByte(offset) != 0);
            case Byte -> JavaConstant.forByte(value.readBufferByte(offset));
            case Short -> JavaConstant.forShort(value.readBufferShort(ByteOrder.nativeOrder(), offset));
            case Char -> JavaConstant.forChar((char) value.readBufferShort(ByteOrder.nativeOrder(), offset));
            case Int -> JavaConstant.forInt(value.readBufferInt(ByteOrder.nativeOrder(), offset));
            case Long -> JavaConstant.forLong(value.readBufferLong(ByteOrder.nativeOrder(), offset));
            case Float -> JavaConstant.forFloat(value.readBufferFloat(ByteOrder.nativeOrder(), offset));
            case Double -> JavaConstant.forDouble(value.readBufferDouble(ByteOrder.nativeOrder(), offset));
            default -> throw new IllegalArgumentException("Unsupported kind: " + kind);
        };
    }

    @Override
    public JavaConstant createHostProxy(Object hostTarget, ResolvedJavaType guestType) {
        Objects.requireNonNull(hostTarget);
        if (!(Objects.requireNonNull(guestType) instanceof EspressoExternalResolvedInstanceType espressoGuestType) || !espressoGuestType.isInterface()) {

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: Invalid input range:
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: Invalid input range:

When it happens

Trigger: Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java:1056 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: Invalid input range:


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