quarkusio/quarkus · error · IllegalArgumentException

At least one package name must be specified

Error message

At least one package name must be specified

What it means

ModuleOpenBuildItem opens packages of one module to another at runtime (JPMS --add-opens equivalent). Both module names must be non-empty and at least one package must be given; the constructor throws IllegalArgumentException when packageNames is empty. (It also rejects using ALL_UNNAMED as the opened module.)

Source

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

     * Create a new ModuleOpenBuildItem instance.
     * We are currently imposing a strict expectation to not refer to the unnamed module
     * as an opening module so to encourage extension maintainers to pick the right module name
     * 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;
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass the package(s) to open explicitly: new ModuleOpenBuildItem("org.foo", "io.quarkus", "org.foo.internal").
  2. To open all packages, enumerate them (e.g. from the module's package list) or produce one item per package rather than passing an empty array.
  3. Skip producing the build item when no packages are configured instead of constructing it with an empty list.

Example fix

// before
buildProducer.produce(new ModuleOpenBuildItem("org.foo", "io.quarkus")); // empty packages
// after
buildProducer.produce(new ModuleOpenBuildItem("org.foo", "io.quarkus", "org.foo.internal"));
Defensive patterns

Strategy: validation

Validate before calling

if (packageNames == null || packageNames.length == 0) {
    return; // or throw with a clear message
}
produce(new ModuleOpenBuildItem(openedModuleName, openingModuleName, packageNames));

Type guard

boolean hasPackages(String... packageNames) {
    return packageNames != null && packageNames.length > 0;
}

Try / catch

try {
    produce(new ModuleOpenBuildItem(opened, opening, packages));
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("At least one package name must be specified")) {
        log.warnf("No packages configured to open from module '%s'; skipping", opened);
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: Constructing new ModuleOpenBuildItem(opened, opening) with an empty String[] / zero arguments, or new ModuleOpenBuildItem("m", "n", new String[0]).

Common situations: Extension code forwarding a config-derived package list that is empty because the config property was unset; calling the varargs constructor with no packages assuming it opens the whole module.

Related errors


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