{"record":{"id":"4bc2cdb973e9a687","repo":"quarkusio/quarkus","slug":"you-re-not-expected-to-use-the-unnamed-module-as-i","errorCode":null,"errorMessage":"You're not expected to use the unnamed module as identifier - please check the javadoc","messagePattern":"You're not expected to use the unnamed module as identifier - please check the javadoc","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/builditem/ModuleEnableNativeAccessBuildItem.java","lineNumber":28,"sourceCode":" * when generating a runnable Jar we can only generate an Enable-Native-Access entry in the Manifest\n * for the modules normally identified by ALL-UNNAMED.\n * This is considered acceptable at the time of writing as extensions are generally placed on the\n * classpath for both fast-jar and uber-jar packaging formats. We expect this to evolve as further packaging\n * formats are introduced which would better leverage the module system.\n * We specifically don't allow enabling native access for \"ALL-UNNAMED\" explicitly while using this API to\n * encourage using the module names that a library has or will have in the near future:\n * for this reason, when a module name is provided which doesn't exist, we map it to the unnamed module.\n * It is not possible to allow native code access to other modules via an agent, other approaches\n * will need to be identified to reconfigure at runtime.\n */\npublic final class ModuleEnableNativeAccessBuildItem extends MultiBuildItem {\n\n    private final String moduleName;\n\n    public ModuleEnableNativeAccessBuildItem(final String moduleName) {\n        this.moduleName = Assert.checkNotEmptyParam(\"moduleName\", moduleName);\n        if (ModuleOpenBuildItem.ALL_UNNAMED.equals(moduleName)) {\n            throw new IllegalArgumentException(\n                    \"You're not expected to use the unnamed module as identifier - please check the javadoc\");\n        }\n    }\n\n    public String moduleName() {\n        return moduleName;\n    }\n}\n","sourceCodeStart":10,"sourceCodeEnd":37,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/builditem/ModuleEnableNativeAccessBuildItem.java#L10-L37","documentation":"ModuleEnableNativeAccessBuildItem requests JPMS native access for a named module. The unnamed module (the classpath, ModuleOpenBuildItem.ALL_UNNAMED) is not a valid identifier here — the javadoc restricts this item to named modules — so the constructor throws IllegalArgumentException when ALL_UNNAMED is passed. Assert also guarantees moduleName itself is non-empty.","triggerScenarios":"Constructing new ModuleEnableNativeAccessBuildItem(ModuleOpenBuildItem.ALL_UNNAMED) or new ModuleEnableNativeAccessBuildItem(\"ALL-UNNAMED\"), i.e. passing the unnamed-module sentinel as moduleName.","commonSituations":"Extension code parameterizing module names from config and defaulting to ALL-UNNAMED; misunderstanding of the javadoc assuming the unnamed module can be targeted like with opens.","solutions":["Pass the actual named module, e.g. new ModuleEnableNativeAccessBuildItem(\"org.apache.commons.lang3\"), matching the module-info name of the library.","If the target code runs on the classpath (unnamed module), it already has no module restrictions for this purpose — remove the build item instead.","If you need ALL-UNNAMED semantics, look at ModuleOpenBuildItem usage for opens where ALL_UNNAMED is valid as the opening module, and drop the native-access request."],"exampleFix":"// before\nbuildProducer.produce(new ModuleEnableNativeAccessBuildItem(ModuleOpenBuildItem.ALL_UNNAMED));\n// after\nbuildProducer.produce(new ModuleEnableNativeAccessBuildItem(\"org.graalvm.nativeimage\"));","handlingStrategy":"validation","validationCode":"if (ModuleOpenBuildItem.ALL_UNNAMED.equals(moduleName)) {\n    throw new IllegalArgumentException(\"ModuleEnableNativeAccessBuildItem requires a named module, not ALL-UNNAMED\");\n}\nproduce(new ModuleEnableNativeAccessBuildItem(moduleName));","typeGuard":"boolean isValidNamedModule(String moduleName) {\n    return moduleName != null && !moduleName.isBlank() && !ModuleOpenBuildItem.ALL_UNNAMED.equals(moduleName);\n}","tryCatchPattern":"try {\n    produce(new ModuleEnableNativeAccessBuildItem(moduleName));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"unnamed module\")) {\n        log.warnf(\"Skipping native-access request for unnamed module '%s'\", moduleName);\n        return;\n    }\n    throw e;\n}","preventionTips":["Only request native access for modules that actually have a module-info name","Never use ALL_UNNAMED as a default for moduleName in config parsing","Read the item's javadoc before building it programmatically"],"tags":["quarkus","jpms","modules","build-time"],"backgroundTag":"invalid-module-identifier","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}