oracle/graal · error · IllegalStateException

Could not find module %s in the boot layer

Error message

Could not find module %s in the boot layer

What it means

Error "Could not find module %s in the boot layer" thrown in oracle/graal.

Source

Thrown at compiler/src/jdk.graal.compiler.vmaccess/src/jdk/graal/compiler/vmaccess/ModuleSupport.java:62

                        "jdk.vm.ci.meta.annotation",
                        "jdk.vm.ci.code");
        ModuleSupport.addExports(VMAccess.class, "jdk.graal.compiler",
                        "jdk.graal.compiler.annotation",
                        "jdk.graal.compiler.phases.util");
        ModuleSupport.addExports(VMAccess.class, "java.base", "sun.reflect.annotation");
    }

    private ModuleSupport() {
    }

    public static void addExports(Class<?> accessingModuleClass, String targetModuleName, String... packageNames) {
        addExports(accessingModuleClass.getModule(), targetModuleName, packageNames);
    }

    public static void addExports(String accessingModuleName, String targetModuleName, String... packageNames) {
        Optional<Module> maybeModule = ModuleLayer.boot().findModule(accessingModuleName);
        if (maybeModule.isEmpty()) {
            throw new IllegalStateException("Could not find module " + accessingModuleName + " in the boot layer");
        }
        addExports(maybeModule.get(), targetModuleName, packageNames);
    }

    public static void addExports(Module accessingModule, String targetModuleName, String... packageNames) {
        Optional<Module> maybeModule = ModuleLayer.boot().findModule(targetModuleName);
        if (maybeModule.isEmpty()) {
            throw new IllegalStateException("Could not find module " + targetModuleName + " in the boot layer");
        }
        addExports(accessingModule, maybeModule.get(), packageNames);
    }

    public static void addExports(Module accessingModule, Module targetModule, String... packageNames) {
        for (String packageName : packageNames) {
            Modules.addExports(targetModule, packageName, accessingModule);
        }
    }

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: Could not find module {} in the boot layer
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: Could not find module {} in the boot layer

When it happens

Trigger: Thrown at compiler/src/jdk.graal.compiler.vmaccess/src/jdk/graal/compiler/vmaccess/ModuleSupport.java:62 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: Could not find module {} in the boot layer


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