oracle/graal · error · GraalError

invalid arguments to BenchmarkDynamicCounters: (err|out),sta

Error message

invalid arguments to BenchmarkDynamicCounters: (err|out),start,end,(err|out),start,end,... (~ matches multiple digits)

What it means

GraalError thrown while parsing -Dgraal.BenchmarkDynamicCounters. The option value is a comma-separated list of triples (err|out, startPattern, endPattern); splitting on ',' must yield a non-empty list whose length is a multiple of 3. This check enforces the triple structure before any stream is wrapped.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/debug/BenchmarkCounters.java:476

                        }
                        break;
                    case 0:
                        if (waitingForEnd) {
                            waitingForEnd = false;
                            running = false;
                            try (PrintStreamScope scope = getPrintStream(options)) {
                                BenchmarkCounters.dump(options, scope.out, (System.nanoTime() - startTime) / 1000000000d, jvmciRuntime.collectCounters(), 100);
                            }
                        }
                        break;
                }
            }
        }

        if (Options.BenchmarkDynamicCounters.getValue(options) != null) {
            String[] arguments = Options.BenchmarkDynamicCounters.getValue(options).split(",");
            if (arguments.length == 0 || (arguments.length % 3) != 0) {
                throw new GraalError("invalid arguments to BenchmarkDynamicCounters: (err|out),start,end,(err|out),start,end,... (~ matches multiple digits)");
            }
            for (int i = 0; i < arguments.length; i += 3) {
                if (arguments[i].equals("err")) {
                    System.setErr(new PrintStream(new BenchmarkCountersOutputStream(System.err, arguments[i + 1], arguments[i + 2])));
                } else if (arguments[i].equals("out")) {
                    System.setOut(new PrintStream(new BenchmarkCountersOutputStream(System.out, arguments[i + 1], arguments[i + 2])));
                } else {
                    throw new GraalError("invalid arguments to BenchmarkDynamicCounters: err|out");
                }
            }
            enabled = true;
        }
        if (Options.GenericDynamicCounters.getValue(options)) {
            enabled = true;
        }
        if (Options.TimedDynamicCounters.getValue(options) > 0) {
            if (LibGraalSupport.inLibGraalRuntime()) {
                throw new GraalError("Use of %s is only supported in jargraal", Options.TimedDynamicCounters.getName());

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Rewrite the value as complete triples: '(err|out),start,end' repeated, e.g. -Dgraal.BenchmarkDynamicCounters='err,1,~'.
  2. Count tokens: total comma-separated fields must be exactly 3 per triple.
  3. Use '~' as a digit wildcard in start/end when matching multiple digits.

Example fix

# before
-Dgraal.BenchmarkDynamicCounters=err,1

# after
-Dgraal.BenchmarkDynamicCounters=err,1,~
Defensive patterns

Strategy: validation

Validate before calling

String v = System.getProperty("graal.BenchmarkDynamicCounters", "");
if (!v.isEmpty()) {
    String[] toks = v.split(",");
    if (toks.length == 0 || toks.length % 3 != 0) {
        throw new IllegalArgumentException("BenchmarkDynamicCounters must be (err|out),start,end triples: " + v);
    }
}

Prevention

When it happens

Trigger: Setting -Dgraal.BenchmarkDynamicCounters with a value whose comma-separated token count is not divisible by 3, e.g. 'err,1' or 'err,1,~,out,2' (5 tokens), or an empty-ish value.

Common situations: Hand-writing the option in benchmark scripts and forgetting one field of a triple; adding a second triple but omitting its end pattern; trailing/missing commas after edits.

Related errors


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