{"record":{"id":"f8c4a44540eaebec","repo":"oracle/graal","slug":"not-starting-with-digits-size","errorCode":null,"errorMessage":"Not starting with digits: {size}","messagePattern":"Not starting with digits: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/EspressoOptions.java","lineNumber":561,"sourceCode":"    public static final OptionKey<Path> PreInitializationClasslist = new OptionKey<>(EMPTY, PATH_OPTION_TYPE);\n\n    private static final OptionType<Long> SIZE_OPTION_TYPE = new OptionType<>(\"Size\", new Function<String, Long>() {\n        private static final int K = 1024;\n\n        @Override\n        public Long apply(String size) {\n            int idx = 0;\n            int len = size.length();\n            for (int i = 0; i < len; i++) {\n                if (Character.isDigit(size.charAt(i))) {\n                    idx++;\n                } else {\n                    break;\n                }\n            }\n\n            if (idx == 0) {\n                throw new IllegalArgumentException(\"Not starting with digits: \" + size);\n            }\n            if (len - idx > 1) {\n                throw new IllegalArgumentException(\"Unit prefix can be at most one character: \" + size);\n            }\n\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;","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/EspressoOptions.java#L543-L579","documentation":"The SIZE_OPTION_TYPE converter (used by --java.MaxDirectMemorySize and similar size options) scans the leading characters of the value and requires at least one leading digit before an optional single unit character. If the very first character is not a digit, it throws 'Not starting with digits'.","triggerScenarios":"Passing --java.MaxDirectMemorySize=1G is fine, but values like 'G1', '-1g' (the converter does not accept signs), empty string, or '1.5G' (the '.' stops the digit scan only if first) fail when no digit appears at position 0.","commonSituations":"Reusing HotSpot -XX:MaxDirectMemorySize values with suffixes first; empty values from unset env vars; localized number formats.","solutions":["Write the value as a plain number of bytes or number+unit with the digit first: 1073741824 or 1G.","Avoid signs, decimals, and thousands separators.","Validate with a regex like ^\\d+[TtGgMmKk]?$ before launching."],"exampleFix":"# before\n--java.MaxDirectMemorySize=1G  # ok\n--java.MaxDirectMemorySize=GB\n\n# after\n--java.MaxDirectMemorySize=1G","handlingStrategy":"validation","validationCode":"if (!size.matches(\"\\\\d+[TtGgMmKk]?\")) throw new ConfigException(\"Bad size: \" + size);","typeGuard":"static boolean validEspressoSize(String s) { return s != null && s.matches(\"\\\\d+[TtGgMmKk]?\"); }","tryCatchPattern":null,"preventionTips":["Accept only ^\\d+[TGMK]?$ in config schemas.","Do not pass signed, decimal, or unit-first values."],"tags":["espresso","graalvm","configuration","options","memory"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}