oracle/graal · error · IllegalArgumentException

Option name must follow '<prefix>' prefix

Error message

Option name must follow '<prefix>' prefix

What it means

stripPrefix removes a known property prefix (e.g. 'graal.' or the libgraal VM-option prefix) to get the option name; if nothing remains (baseName.isEmpty()), the property was exactly the prefix with no option name, and IllegalArgumentException('Option name must follow ... prefix') is thrown while parsing -Dgraal.* properties.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalOptionValues.java:144

            }

            if (!vmOptionSettings.isEmpty()) {
                LibGraalSupport libgraal = LibGraalSupport.INSTANCE;
                if (libgraal != null) {
                    libgraal.notifyOptions(vmOptionSettings);
                } else {
                    System.err.printf("WARNING: Ignoring the following libgraal VM option(s) while executing jargraal: %s%n", vmOptionSettings);
                }
            }
            OptionsParser.parseOptions(compilerOptionSettings, compilerOptionValues, descriptors);
            return compilerOptionValues;
        }
    }

    private static String stripPrefix(String name, String prefix) {
        String baseName = name.substring(prefix.length());
        if (baseName.isEmpty()) {
            throw new IllegalArgumentException("Option name must follow '" + prefix + "' prefix");
        }
        return baseName;
    }

    private static OptionValues initializeOptions() {
        EconomicMap<OptionKey<?>, Object> values = parseOptions();
        OptionValues options = new OptionValues(values);
        if (HotSpotGraalCompiler.Options.CrashAtThrowsOOME.getValue(options) && HotSpotGraalCompiler.Options.CrashAtIsFatal.getValue(options) != 0) {
            throw new IllegalArgumentException("CrashAtThrowsOOME and CrashAtIsFatal cannot both be enabled");
        }
        return options;
    }

    static void printProperties(OptionValues compilerOptions, PrintStream out) {
        boolean all = HotSpotGraalCompilerFactory.Options.PrintPropertiesAll.getValue(compilerOptions);
        compilerOptions.printHelp(OptionsParser.getOptionsLoader(), out, GRAAL_OPTION_PROPERTY_PREFIX, all);
        LibGraalSupport libgraal = LibGraalSupport.INSTANCE;
        if (all && libgraal != null) {

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Find and remove the empty -Dgraal. style property (check the command line, JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS, and JAVA_OPTS env)
  2. Fix the script so variable expansion cannot produce an empty option name (guard with a conditional or :+ expansion)
  3. Inspect the failing prefix in the message to know which property family is truncated

Example fix

# before (VAR is empty -> "-Dgraal.")
exec java -Dgraal.${GRAAL_EXTRA_OPT} MyApp

# after
exec java ${GRAAL_EXTRA_OPT:+-Dgraal.$GRAAL_EXTRA_OPT} MyApp
Defensive patterns

Strategy: validation

Validate before calling

for (String k : System.getProperties().stringPropertyNames()) {
    if (k.equals("graal.") || k.endsWith(".") && k.startsWith("graal")) { /* reject misconfigured property set */ }
}

Prevention

When it happens

Trigger: Setting a property that equals the bare prefix — e.g. -Dgraal. (or the libgraal VM option prefix with no suffix) on the java command line or in the environment; the check runs for every property whose name starts with a recognized prefix during HotSpotGraalOptionValues.parseOptions.

Common situations: Shell scripts that concatenate an empty variable into -Dgraal.$VAR; quoted empty strings in JAVA_TOOL_OPTIONS/JDK_JAVA_OPTIONS; typos truncating a property name to just the prefix.

Related errors


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