quarkusio/quarkus · error · IllegalArgumentException
The unnamed module cannot be opened to other modules
Error message
The unnamed module cannot be opened to other modules
What it means
ModuleOpenBuildItem declares JPMS module opens made by the Quarkus build. The constructor rejects ALL_UNNAMED as the module being opened to, because the unnamed module (the classpath) has no packages to open and JPMS forbids opening it; such a call is always a caller mistake.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/builditem/ModuleOpenBuildItem.java:65
* in preparation for more extensive modularization.
* If the library to which you're opening to isn't on the module path yet at this point, it
* should still be beneficial to refer to it by the expected module name.
* 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;
}View on GitHub (pinned to e1c734241f)
Solutions
- Pass a real named module name (the module containing the packages) as openedModuleName instead of ALL_UNNAMED
- If you intend to open to everything, omit openedModuleName / use the ALL_UNNAMED semantics on the opening side per the Javadocs
- Check the Javadoc of ModuleOpenBuildItem for correct argument order and semantics
Example fix
// before
new ModuleOpenBuildItem("ALL_UNNAMED", "com.example.pkg");
// after
new ModuleOpenBuildItem("com.example.module", "com.example.pkg"); Defensive patterns
Strategy: validation
Validate before calling
if ("ALL_UNNAMED".equals(openedModuleName)) throw new IllegalArgumentException("openedModuleName must be a named module"); Type guard
boolean isValidModuleName(String n) { return n != null && !n.isBlank() && !"ALL_UNNAMED".equals(n); } Prevention
- Never pass ALL_UNNAMED as the opened module; only real module names
- Read the ModuleOpenBuildItem Javadocs before use
- Keep argument order (opening module, packages, opened module) clear in call sites
When it happens
Trigger: Calling new ModuleOpenBuildItem("ALL_UNNAMED", ...) or passing Module.OPEN_ALL_UNNAMED-style constant as openedModuleName during build-step processing.
Common situations: Writing a custom build step that mirrors java.lang.Module.addOpens and accidentally using the ALL_UNNAMED constant for the target module instead of the opening module; porting code that opened the classpath to reflection.
Related errors
- The unnamed module cannot be used as an opening module ident
- Name cannot start with '/':${name}
- You're not expected to use the unnamed module as identifier
- messageStarts cannot be empty
- 'target' can only be a class, a field or a method: <target>
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/22fc2c7f5301fe5d.
Report an issue: GitHub.