{"record":{"id":"04de453703b49d79","repo":"oracle/graal","slug":"unrecognized-unit-prefix-size-use-t-g-m","errorCode":null,"errorMessage":"Unrecognized unit prefix: {size} use `T`, `G`, `M`, or `k`.","messagePattern":"Unrecognized unit prefix: (.+?) use `T`, `G`, `M`, or `k`\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/EspressoOptions.java","lineNumber":584,"sourceCode":"\n            long result = Long.parseLong(size.substring(0, idx));\n\n            if (idx < len) {\n                switch (size.charAt(idx)) {\n                    case 'T': // fallthrough\n                    case 't':\n                        return result * K * K * K * K;\n                    case 'G': // fallthrough\n                    case 'g':\n                        return result * K * K * K;\n                    case 'M': // fallthrough\n                    case 'm':\n                        return result * K * K;\n                    case 'K': // fallthrough\n                    case 'k':\n                        return result * K;\n                    default:\n                        throw new IllegalArgumentException(\"Unrecognized unit prefix: \" + size + \" use `T`, `G`, `M`, or `k`.\");\n                }\n            }\n            return result;\n\n        }\n    });\n\n    @Option(help = \"Maximum total size of NIO direct-buffer allocations.\", //\n                    category = OptionCategory.EXPERT, //\n                    stability = OptionStability.STABLE, usageSyntax = \"<size>[<unit>]\") //\n    public static final OptionKey<Long> MaxDirectMemorySize = new OptionKey<>(-1L, SIZE_OPTION_TYPE);\n\n    @Option(help = \"Load native agents from standard library paths. \\\\n\" +\n                    \"Keys represent the agent library name, values are the corresponding agent options.\\\\n\" +\n                    \"Agents are not fully implemented yet.\", //\n                    category = OptionCategory.INTERNAL, //\n                    stability = OptionStability.EXPERIMENTAL, //\n                    usageSyntax = \"<agentOptions>\") //","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/EspressoOptions.java#L566-L602","documentation":"The final switch of the size converter accepts only T/t, G/g, M/m, K/k as the single unit character. Any other character after the digits (e.g. 'B', 'b', 'i') falls to default and throws, advising the four supported prefixes.","triggerScenarios":"--java.MaxDirectMemorySize=16B, 1b, or 1x - the value starts with digits and has exactly one trailing character, but that character is not T/G/M/K.","commonSituations":"Writing '16B' for bytes (use a plain number instead); binary-unit 'i' from GiB notation; typos.","solutions":["Use T, G, M, or k (case-insensitive) as the unit.","For plain bytes, omit the unit entirely.","Beware that 'b' is NOT accepted - use no unit for bytes."],"exampleFix":"# before\n--java.MaxDirectMemorySize=16B\n\n# after\n--java.MaxDirectMemorySize=16   # bytes, no unit","handlingStrategy":"validation","validationCode":"if (!size.matches(\"\\\\d+([TtGgMmKk])?\")) throw new ConfigException(\"Unit must be T/G/M/k: \" + size);","typeGuard":"static boolean validUnit(String s) { return s != null && s.matches(\"\\\\d+[TtGgMmKk]?\"); }","tryCatchPattern":null,"preventionTips":["Plain bytes = no suffix at all.","Remember 'B'/'b' are rejected."],"tags":["espresso","graalvm","configuration","options","memory"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}