{"record":{"id":"9c5559cf1b0b8bd7","repo":"oracle/graal","slug":"illegal-call-to-maxvalue-on","errorCode":null,"errorMessage":"illegal call to maxValue on ","messagePattern":"illegal call to maxValue 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":370,"sourceCode":"        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;\n            case Int:\n                return java.lang.Integer.MAX_VALUE;\n            case Long:\n                return java.lang.Long.MAX_VALUE;\n            case Float:\n                return java.lang.Float.floatToRawIntBits(java.lang.Float.MAX_VALUE);\n            case Double:\n                return java.lang.Double.doubleToRawLongBits(java.lang.Double.MAX_VALUE);\n            default:\n                throw new IllegalArgumentException(\"illegal call to maxValue on \" + this);\n        }\n    }\n\n    /**\n     * Number of bytes that are necessary to represent a value of this kind.\n     *\n     * @return the number of bytes\n     */\n    public int getByteCount() {\n        if (this == Boolean) {\n            return 1;\n        } else {\n            return getBitCount() >> 3;\n        }\n    }\n\n    /**\n     * Number of bits that are necessary to represent a value of this kind.","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaKind.java#L352-L388","documentation":"JavaKind.getMaxValue is the counterpart of getMinValue: it returns the maximum bit-pattern value for Boolean..Double only. Invoking it on Void, Illegal, or Object throws IllegalArgumentException 'illegal call to maxValue on <kind>'.","triggerScenarios":"Calling kind.getMaxValue() on JavaKind.Object, JavaKind.Void, or JavaKind.Illegal, usually from generic range-analysis, interval, or test-harness code that walks every JavaKind constant.","commonSituations":"Range/bounds logic shared across all kinds; generated exhaustive switch over JavaKind.values(); refactoring code that previously only received primitive kinds.","solutions":["Filter non-numeric kinds first: only call getMaxValue() when kind.isPrimitive() && kind != JavaKind.Void","Add an explicit default branch in your switch for Object/Void/Illegal instead of falling through"],"exampleFix":"// before\nlong max = kind.getMaxValue(); // crashes for Object/Void/Illegal\n\n// after\nif (kind.isPrimitive() && kind != JavaKind.Void) {\n    long max = kind.getMaxValue();\n}","handlingStrategy":"type-guard","validationCode":"if (!kind.isPrimitive() || kind == JavaKind.Void) throw new IllegalArgumentException(\"no maxValue for \" + kind);","typeGuard":"static boolean hasMinMax(JavaKind k) { return k.isPrimitive() && k != JavaKind.Void; }","tryCatchPattern":null,"preventionTips":["Guard all numeric JavaKind accessors with the same primitive-and-not-void predicate","Keep Object/Void/Illegal branches explicit in switches over JavaKind"],"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"}