quarkusio/quarkus · error · IllegalArgumentException

The unnamed module cannot be used as an opening module ident

Error message

The unnamed module cannot be used as an opening module identifier: please read the Javadocs for more details

What it means

ModuleOpenBuildItem also rejects ALL_UNNAMED as the module doing the opening. The opening module must be a named module because Quarkus records opens on behalf of named modules in the resulting image; the unnamed module cannot be an identifier here.

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/builditem/ModuleOpenBuildItem.java:68

     * When a module name is specified which couldn't be identified by name, we'll fallback
     * the opening module name to the unnamed module to allow for an easier transition.
     *
     * @param openedModuleName The name of the module which needs to be opened.
     * @param openingModuleName The name of the module which is being granted access.
     * @param packageNames The packages which are being opened. At least one must be specified.
     */
    public ModuleOpenBuildItem(String openedModuleName, String openingModuleName, String... packageNames) {
        this.openedModuleName = Assert.checkNotEmptyParam("openedModuleName", openedModuleName);
        this.openingModuleName = Assert.checkNotEmptyParam("openingModuleName", openingModuleName);
        this.packageNames = Assert.checkNotEmptyParam("packageNames", Set.of(packageNames));
        if (packageNames.length == 0) {
            throw new IllegalArgumentException("At least one package name must be specified");
        }
        if (ALL_UNNAMED.equals(openedModuleName)) {
            throw new IllegalArgumentException("The unnamed module cannot be opened to other modules");
        }
        if (ALL_UNNAMED.equals(openingModuleName)) {
            throw new IllegalArgumentException(
                    "The unnamed module cannot be used as an opening module identifier: please read the Javadocs for more details");
        }
    }

    public String openedModuleName() {
        return openedModuleName;
    }

    public String openingModuleName() {
        return openingModuleName;
    }

    public Set<String> packageNames() {
        return packageNames;
    }

    @Override
    public String toString() {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Swap/reorder the arguments so ALL_UNNAMED (if needed at all) is the openedModuleName, not the openingModuleName
  2. Use the concrete name of the module performing the open
  3. Read the ModuleOpenBuildItem Javadocs as the message suggests

Example fix

// before
new ModuleOpenBuildItem("ALL_UNNAMED", "com.example.pkg", "java.base");
// after
new ModuleOpenBuildItem("com.example.module", "com.example.pkg");
Defensive patterns

Strategy: validation

Validate before calling

if ("ALL_UNNAMED".equals(openingModuleName)) throw new IllegalArgumentException("openingModuleName must be a named module");

Type guard

boolean isNamedModule(String n) { return n != null && !n.isBlank() && !"ALL_UNNAMED".equals(n); }

Prevention

When it happens

Trigger: Calling new ModuleOpenBuildItem(packageNames..., openedModuleName) where the openingModuleName argument is "ALL_UNNAMED".

Common situations: Mixing up the parameter order so the ALL_UNNAMED constant intended for the 'opened to' side lands in the opening-module slot; copy-paste from reflection code using "ALL_UNNAMED".

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/bb259cb926d724bc. Report an issue: GitHub.