{"record":{"id":"e549daa4a1fce767","repo":"oracle/graal","slug":"illegal-call-to-minvalue-on","errorCode":null,"errorMessage":"illegal call to minValue on ","messagePattern":"illegal call to minValue on ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaKind.java","lineNumber":342,"sourceCode":"        switch (this) {\n            case Boolean:\n                return 0;\n            case Byte:\n                return java.lang.Byte.MIN_VALUE;\n            case Char:\n                return java.lang.Character.MIN_VALUE;\n            case Short:\n                return java.lang.Short.MIN_VALUE;\n            case Int:\n                return java.lang.Integer.MIN_VALUE;\n            case Long:\n                return java.lang.Long.MIN_VALUE;\n            case Float:\n                return java.lang.Float.floatToRawIntBits(java.lang.Float.MIN_VALUE);\n            case Double:\n                return java.lang.Double.doubleToRawLongBits(java.lang.Double.MIN_VALUE);\n            default:\n                throw new IllegalArgumentException(\"illegal call to minValue on \" + this);\n        }\n    }\n\n    /**\n     * Gets the maximum value that can be represented as a value of this kind.\n     *\n     * @return the maximum value represented as a {@code long}\n     */\n    public long getMaxValue() {\n        switch (this) {\n            case Boolean:\n                return 1;\n            case Byte:\n                return java.lang.Byte.MAX_VALUE;\n            case Char:\n                return java.lang.Character.MAX_VALUE;\n            case Short:\n                return java.lang.Short.MAX_VALUE;","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaKind.java#L324-L360","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Guard the call with a kind filter such as kind.isPrimitive() && kind != JavaKind.Void before invoking getMinValue()","Handle Object/Void/Illegal with an explicit branch (or skip them) when iterating JavaKind.values()"],"exampleFix":"// before\nlong min = kind.getMinValue(); // crashes for Object/Void/Illegal\n\n// after\nlong min = (kind.isPrimitive() && kind != JavaKind.Void) ? kind.getMinValue() : throwElse(kind);","handlingStrategy":"type-guard","validationCode":"if (!kind.isPrimitive() || kind == JavaKind.Void) throw new IllegalArgumentException(\"no minValue for \" + kind);","typeGuard":"static boolean hasMinMax(JavaKind k) { return k.isPrimitive() && k != JavaKind.Void; }","tryCatchPattern":null,"preventionTips":["Skip Object/Void/Illegal explicitly when enumerating JavaKind.values()","In tests, iterate only over primitive kinds for numeric accessors"],"tags":["espresso","classfile","javakind","enum"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}