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

  1. Read the chained cause of this exception to see the exact JVM rejection reason
  2. Verify the package exists in the source module with jar --describe-module or java --describe-module
  3. Align the build JDK with a version supported by your Quarkus version
  4. 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

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


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