{"record":{"id":"5c9bb8ca929b2e7f","repo":"quarkusio/quarkus","slug":"failed-to-invoke-impladdopens","errorCode":null,"errorMessage":"Failed to invoke implAddOpens","messagePattern":"Failed to invoke implAddOpens","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/jvm/ReflectiveAccessModulesReconfigurer.java","lineNumber":99,"sourceCode":"                    \"This must be run with JVM parameter '--add-opens=java.base/java.lang.invoke=ALL-UNNAMED'\", e);\n        }\n    }\n\n    /**\n     * Uses the MethodHandle to open a package.\n     *\n     * @param sourceModule The module to open\n     * @param packageName The package to open\n     * @param targetModule The module to open to\n     */\n    private void addOpens(Module sourceModule, String packageName, Module targetModule) {\n        try {\n            implAddOpensHandle.invokeExact(sourceModule, packageName, targetModule);\n            logger.debugf(\"Successfully opened module %s/%s to %s\",\n                    sourceModule.getName(), packageName, targetModule.isNamed() ? targetModule.getName() : \"UNNAMED\");\n        } catch (Throwable e) {\n            // MethodHandle.invokeExact throws Throwable\n            throw new RuntimeException(\"Failed to invoke implAddOpens\", e);\n        }\n    }\n\n}\n","sourceCodeStart":81,"sourceCodeEnd":104,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/jvm/ReflectiveAccessModulesReconfigurer.java#L81-L104","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before\njava --list-modules | grep java.base   # assume package com.sun.foo exists in java.base\n// after\njava --describe-module java.base | grep com.sun.foo   # confirm before relying on reflective open","handlingStrategy":"try-catch","validationCode":"// Verify the package is actually defined by the module before opening it\nSet<String> pkgs = Set.of(sourceModule.getPackages());\nif (!pkgs.contains(packageName)) {\n    throw new IllegalArgumentException(\"Package \" + packageName + \" not in module \" + sourceModule.getName());\n}","typeGuard":null,"tryCatchPattern":"try {\n    // deployment step using reflective module open\n} catch (RuntimeException e) {\n    if (\"Failed to invoke implAddOpens\".equals(e.getMessage())) {\n        log.errorf(e.getCause(), \"implAddOpens rejected package %s on module %s\", packageName, sourceModule.getName());\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["quarkus","jpms","modules","methodhandle","jdk"],"backgroundTag":"jpms-module-access-denied","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}