oracle/graal · critical · GraalError

%s garbage collector is not supported by Graal

Error message

%s garbage collector is not supported by Graal

What it means

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.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java:106

        return klassEncoding;
    }

    public boolean useSerialGC() {
        return gc == HotSpotGraalRuntime.HotSpotGC.Serial;
    }

    public boolean useG1GC() {
        return gc == HotSpotGraalRuntime.HotSpotGC.G1;
    }

    public final HotSpotGraalRuntime.HotSpotGC gc = getSelectedGC();

    private HotSpotGraalRuntime.HotSpotGC getSelectedGC() throws GraalError {
        HotSpotGraalRuntime.HotSpotGC selected = null;
        for (HotSpotGraalRuntime.HotSpotGC value : HotSpotGraalRuntime.HotSpotGC.values()) {
            if (value.isSelected(this)) {
                if (!value.supported) {
                    throw new GraalError(value.name() + " garbage collector is not supported by Graal");
                }
                if (selected != null) {
                    throw new GraalError("Multiple garbage collectors selected: " + selected + " " + value);
                }
                selected = value;
            }
        }
        if (selected == null) {
            // Exactly one GC flag is guaranteed to be selected.
            selected = HotSpotGraalRuntime.HotSpotGC.Serial;
        }
        return selected;
    }

    /**
     * Determines if {@code -Xcomp} (or the equivalent thereof) was specified as a JVM argument.
     */
    public final boolean xcompMode = !access.getFlag("UseInterpreter", Boolean.class);

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Switch to a supported collector: -XX:+UseG1GC (or Parallel/Serial/SerialGC depending on platform) when using Graal
  2. Keep the unsupported GC but disable Graal/JVMCI compilation if Graal is optional for that run
  3. Track the Graal release notes — collector support varies by version and architecture

Example fix

# before
java -XX:+UseZGC -XX:+UseJVMCICompiler MyApp
# GraalError: ZGC garbage collector is not supported by Graal

# after
java -XX:+UseG1GC -XX:+UseJVMCICompiler MyApp
Defensive patterns

Strategy: validation

Validate before calling

// before enabling Graal, check the GC flag you will use is in the supported set (G1, Parallel, Serial, Epsilon where applicable)
if (List.of("-XX:+UseZGC", "-XX:+UseShenandoahGC").stream().anyMatch(cmd::contains)) { /* refuse or drop -XX:+UseJVMCICompiler */ }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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