oracle/graal · error · IllegalArgumentException

illegal call to minValue on

Error message

illegal call to minValue on 

What it means

JavaKind.getMinValue returns the minimum value of a primitive kind as a bit pattern in a long. It only covers Boolean..Double; calling it on Void, Illegal, or Object throws IllegalArgumentException 'illegal call to minValue on <kind>' because those kinds have no numeric minimum.

Source

Thrown at espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaKind.java:342

        switch (this) {
            case Boolean:
                return 0;
            case Byte:
                return java.lang.Byte.MIN_VALUE;
            case Char:
                return java.lang.Character.MIN_VALUE;
            case Short:
                return java.lang.Short.MIN_VALUE;
            case Int:
                return java.lang.Integer.MIN_VALUE;
            case Long:
                return java.lang.Long.MIN_VALUE;
            case Float:
                return java.lang.Float.floatToRawIntBits(java.lang.Float.MIN_VALUE);
            case Double:
                return java.lang.Double.doubleToRawLongBits(java.lang.Double.MIN_VALUE);
            default:
                throw new IllegalArgumentException("illegal call to minValue on " + this);
        }
    }

    /**
     * Gets the maximum value that can be represented as a value of this kind.
     *
     * @return the maximum value represented as a {@code long}
     */
    public long getMaxValue() {
        switch (this) {
            case Boolean:
                return 1;
            case Byte:
                return java.lang.Byte.MAX_VALUE;
            case Char:
                return java.lang.Character.MAX_VALUE;
            case Short:
                return java.lang.Short.MAX_VALUE;

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Guard the call with a kind filter such as kind.isPrimitive() && kind != JavaKind.Void before invoking getMinValue()
  2. Handle Object/Void/Illegal with an explicit branch (or skip them) when iterating JavaKind.values()

Example fix

// before
long min = kind.getMinValue(); // crashes for Object/Void/Illegal

// after
long min = (kind.isPrimitive() && kind != JavaKind.Void) ? kind.getMinValue() : throwElse(kind);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!kind.isPrimitive() || kind == JavaKind.Void) throw new IllegalArgumentException("no minValue for " + kind);

Type guard

static boolean hasMinMax(JavaKind k) { return k.isPrimitive() && k != JavaKind.Void; }

Prevention

When it happens

Trigger: Calling kind.getMinValue() on JavaKind.Void, JavaKind.Illegal, or JavaKind.Object — typically in generic code that iterates all JavaKind values (bounds analysis, constant folding, table generation) without filtering.

Common situations: Porting code that assumed only primitive kinds exist; switch/table generation over JavaKind.values() that forgets the non-numeric members; unit tests enumerating every enum constant and calling every accessor.

Related errors


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