{"record":{"id":"9ff2aaa056929c77","repo":"oracle/graal","slug":"use-of-s-is-only-supported-in-jargraal","errorCode":null,"errorMessage":"Use of %s is only supported in jargraal","messagePattern":"Use of (.+?) is only supported in jargraal","errorType":"error_code","errorClass":"GraalError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/debug/BenchmarkCounters.java","lineNumber":494,"sourceCode":"                throw new GraalError(\"invalid arguments to BenchmarkDynamicCounters: (err|out),start,end,(err|out),start,end,... (~ matches multiple digits)\");\n            }\n            for (int i = 0; i < arguments.length; i += 3) {\n                if (arguments[i].equals(\"err\")) {\n                    System.setErr(new PrintStream(new BenchmarkCountersOutputStream(System.err, arguments[i + 1], arguments[i + 2])));\n                } else if (arguments[i].equals(\"out\")) {\n                    System.setOut(new PrintStream(new BenchmarkCountersOutputStream(System.out, arguments[i + 1], arguments[i + 2])));\n                } else {\n                    throw new GraalError(\"invalid arguments to BenchmarkDynamicCounters: err|out\");\n                }\n            }\n            enabled = true;\n        }\n        if (Options.GenericDynamicCounters.getValue(options)) {\n            enabled = true;\n        }\n        if (Options.TimedDynamicCounters.getValue(options) > 0) {\n            if (LibGraalSupport.inLibGraalRuntime()) {\n                throw new GraalError(\"Use of %s is only supported in jargraal\", Options.TimedDynamicCounters.getName());\n            }\n            Thread thread = new Thread(new Runnable() {\n                long lastTime = System.nanoTime();\n\n                @Override\n                public void run() {\n                    try (PrintStreamScope scope = getPrintStream(options)) {\n                        while (true) { // TERMINATION ARGUMENT: busy waiting loop\n                            try {\n                                Thread.sleep(Options.TimedDynamicCounters.getValue(options));\n                            } catch (InterruptedException e) {\n                            }\n                            long time = System.nanoTime();\n                            dump(options, scope.out, (time - lastTime) / 1000000000d, jvmciRuntime.collectCounters(), 10);\n                            lastTime = time;\n                        }\n                    }\n                }","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/debug/BenchmarkCounters.java#L476-L512","documentation":"GraalError thrown during BenchmarkCounters initialization when -Dgraal.TimedDynamicCounters is set to a positive interval while running inside libgraal (the SVM-compiled in-process compiler library). Timed dumping relies on starting a Java Thread that periodically collects counters; libgraal's image heap/runtime does not support this, and the option is only meaningful in jargraal (JVM-embedded Java-mode Graal).","triggerScenarios":"Running with -XX:+UseJVMCICompiler in the default libgraal mode (no -Dgraal.JVMCILibGraal=false or equivalent) together with -Dgraal.TimedDynamicCounters=<ms>>0; LibGraalSupport.inLibGraalRuntime() returns true and the check fires.","commonSituations":"Reusing a benchmarking flag set that was tuned for jargraal on a JDK that now defaults to libgraal; nightly perf scripts that time-slice counter dumps.","solutions":["Drop -Dgraal.TimedDynamicCounters when running libgraal.","Switch to jargraal mode if you need periodic dumps (run the compiler as Java, e.g. -Dgraal.JVMCILibGraal=false where supported).","Use one-shot counter dumps (-Dgraal.BenchmarkDynamicCounters triples or dump-on-exit) instead of timed dumps under libgraal."],"exampleFix":"# before\n-XX:+UseJVMCICompiler -Dgraal.TimedDynamicCounters=1000\n# GraalError: Use of TimedDynamicCounters is only supported in jargraal\n\n# after\n-XX:+UseJVMCICompiler  # timed counters removed under libgraal","handlingStrategy":"validation","validationCode":"// Do not set TimedDynamicCounters when running libgraal\nboolean libgraal = Boolean.parseBoolean(System.getProperty(\"graal.JVMCILibGraal\", \"true\"));\nlong timed = Long.getLong(\"graal.TimedDynamicCounters\", 0);\nif (libgraal && timed > 0) {\n    throw new IllegalStateException(\"graal.TimedDynamicCounters requires jargraal mode; unset it or disable libgraal\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Split benchmark flag sets into 'libgraal-safe' and 'jargraal-only' groups.","Assert runtime mode before applying jargraal-only options."],"tags":["graalvm","benchmarking","libgraal","configuration"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}