{"record":{"id":"ea4e2177a81e8c90","repo":"oracle/graal","slug":"s-garbage-collector-is-not-supported-by-graal","errorCode":null,"errorMessage":"%s garbage collector is not supported by Graal","messagePattern":"(.+?) garbage collector is not supported by Graal","errorType":"exception","errorClass":"GraalError","httpStatus":null,"severity":"critical","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java","lineNumber":106,"sourceCode":"        return klassEncoding;\n    }\n\n    public boolean useSerialGC() {\n        return gc == HotSpotGraalRuntime.HotSpotGC.Serial;\n    }\n\n    public boolean useG1GC() {\n        return gc == HotSpotGraalRuntime.HotSpotGC.G1;\n    }\n\n    public final HotSpotGraalRuntime.HotSpotGC gc = getSelectedGC();\n\n    private HotSpotGraalRuntime.HotSpotGC getSelectedGC() throws GraalError {\n        HotSpotGraalRuntime.HotSpotGC selected = null;\n        for (HotSpotGraalRuntime.HotSpotGC value : HotSpotGraalRuntime.HotSpotGC.values()) {\n            if (value.isSelected(this)) {\n                if (!value.supported) {\n                    throw new GraalError(value.name() + \" garbage collector is not supported by Graal\");\n                }\n                if (selected != null) {\n                    throw new GraalError(\"Multiple garbage collectors selected: \" + selected + \" \" + value);\n                }\n                selected = value;\n            }\n        }\n        if (selected == null) {\n            // Exactly one GC flag is guaranteed to be selected.\n            selected = HotSpotGraalRuntime.HotSpotGC.Serial;\n        }\n        return selected;\n    }\n\n    /**\n     * Determines if {@code -Xcomp} (or the equivalent thereof) was specified as a JVM argument.\n     */\n    public final boolean xcompMode = !access.getFlag(\"UseInterpreter\", Boolean.class);","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java#L88-L124","documentation":"GraalHotSpotVMConfig.getSelectedGC iterates HotSpotGC values; when the currently selected HotSpot garbage collector flag reports itself as chosen but its supported field is false, GraalError '<GC name> garbage collector is not supported by Graal' is thrown during VM config init, aborting Graal compiler bootstrap.","triggerScenarios":"Booting the JVM with -XX:+UseZGC or -XX:+UseShenandoahGC (collectors whose HotSpotGC enum entry has supported=false) together with the JVMCI/Graal compiler (-XX:+UseJVMCICompiler / libgraal).","commonSituations":"CI or container images defaulting to ZGC/Shenandoah for low-latency profiles while enabling Graal; upgrading a JVM whose default GC became one Graal does not support; mixing GC flags in benchmark scripts.","solutions":["Switch to a supported collector: -XX:+UseG1GC (or Parallel/Serial/SerialGC depending on platform) when using Graal","Keep the unsupported GC but disable Graal/JVMCI compilation if Graal is optional for that run","Track the Graal release notes — collector support varies by version and architecture"],"exampleFix":"# before\njava -XX:+UseZGC -XX:+UseJVMCICompiler MyApp\n# GraalError: ZGC garbage collector is not supported by Graal\n\n# after\njava -XX:+UseG1GC -XX:+UseJVMCICompiler MyApp","handlingStrategy":"validation","validationCode":"// before enabling Graal, check the GC flag you will use is in the supported set (G1, Parallel, Serial, Epsilon where applicable)\nif (List.of(\"-XX:+UseZGC\", \"-XX:+UseShenandoahGC\").stream().anyMatch(cmd::contains)) { /* refuse or drop -XX:+UseJVMCICompiler */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default containers/CI to G1 when Graal is enabled","Validate GC+compiler flag combinations in launch scripts","Re-check GC support on each GraalVM upgrade"],"tags":["graal-compiler","gc","hotspot","startup"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}