quarkusio/quarkus · error · RuntimeException
Failed to invoke implAddOpens
Error message
Failed to invoke implAddOpens
What it means
ReflectiveAccessModulesReconfigurer.addOpens() invokes the previously acquired MethodHandle for Module#implAddOpens. Because MethodHandle.invokeExact can throw any Throwable, any failure while actually opening the package is wrapped as this RuntimeException with the original cause attached. The handle existed, but executing it failed.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/jvm/ReflectiveAccessModulesReconfigurer.java:99
"This must be run with JVM parameter '--add-opens=java.base/java.lang.invoke=ALL-UNNAMED'", e);
}
}
/**
* Uses the MethodHandle to open a package.
*
* @param sourceModule The module to open
* @param packageName The package to open
* @param targetModule The module to open to
*/
private void addOpens(Module sourceModule, String packageName, Module targetModule) {
try {
implAddOpensHandle.invokeExact(sourceModule, packageName, targetModule);
logger.debugf("Successfully opened module %s/%s to %s",
sourceModule.getName(), packageName, targetModule.isNamed() ? targetModule.getName() : "UNNAMED");
} catch (Throwable e) {
// MethodHandle.invokeExact throws Throwable
throw new RuntimeException("Failed to invoke implAddOpens", e);
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Read the chained cause of this exception to see the exact JVM rejection reason
- Verify the package exists in the source module with jar --describe-module or java --describe-module
- Align the build JDK with a version supported by your Quarkus version
- Prefer explicit --add-opens JVM flags over reflective module reconfiguration if the failures persist
Example fix
// before java --list-modules | grep java.base # assume package com.sun.foo exists in java.base // after java --describe-module java.base | grep com.sun.foo # confirm before relying on reflective open
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the package is actually defined by the module before opening it
Set<String> pkgs = Set.of(sourceModule.getPackages());
if (!pkgs.contains(packageName)) {
throw new IllegalArgumentException("Package " + packageName + " not in module " + sourceModule.getName());
} Try / catch
try {
// deployment step using reflective module open
} catch (RuntimeException e) {
if ("Failed to invoke implAddOpens".equals(e.getMessage())) {
log.errorf(e.getCause(), "implAddOpens rejected package %s on module %s", packageName, sourceModule.getName());
}
throw e;
} Prevention
- Always inspect the chained cause for the exact JVM rejection
- Validate scanned package names against module.getPackages() before opening
- Keep build JDK aligned with the Quarkus-supported matrix
- Fall back to explicit --add-opens JVM flags when reflective opens are unreliable
When it happens
Trigger: implAddOpensHandle.invokeExact(sourceModule, packageName, targetModule) throws — e.g. the package does not exist in the source module (IllegalArgumentException from the JVM), the module was already redefined/invalid, or an internal access check fails at invocation time.
Common situations: Computed package names that are not actually defined by the module (stale classpath scanning results); JDK version differences where packages moved or were removed; opening the same package concurrently/race with other tooling; unusual module graphs (unnamed module edge cases).
Related errors
- Failed to redefine module ${moduleName}
- Failed to acquire handle to Module#implAddOpens. This must b
- You're not expected to use the unnamed module as identifier
- At least one package name must be specified
- Quarkus applications require Java 21 or higher to build
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/5c9bb8ca929b2e7f.
Report an issue: GitHub.