From ea3260f594b945427f6afb2b03014801483e90e9 Mon Sep 17 00:00:00 2001 From: Matej Novotny Date: Tue, 28 Jul 2026 14:32:59 +0200 Subject: [PATCH 1/3] Add module-info.java to weld-api and weld-spi --- pom.xml | 7 +++++ weld-spi/pom.xml | 5 ++++ weld-spi/src/main/java/module-info.java | 36 +++++++++++++++++++++++++ weld/src/main/java/module-info.java | 18 +++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 weld-spi/src/main/java/module-info.java create mode 100644 weld/src/main/java/module-info.java diff --git a/pom.xml b/pom.xml index 6e407ed6..6aca8d60 100644 --- a/pom.xml +++ b/pom.xml @@ -105,6 +105,7 @@ 2.2.0 6.1.0 3.1.1 + 6.0.1 @@ -193,6 +194,12 @@ + + jakarta.el + jakarta.el-api + ${el.api.version} + + org.testng diff --git a/weld-spi/pom.xml b/weld-spi/pom.xml index 6a335212..0d2c751a 100644 --- a/weld-spi/pom.xml +++ b/weld-spi/pom.xml @@ -73,6 +73,11 @@ true + + jakarta.el + jakarta.el-api + true + diff --git a/weld-spi/src/main/java/module-info.java b/weld-spi/src/main/java/module-info.java new file mode 100644 index 00000000..1f438ad4 --- /dev/null +++ b/weld-spi/src/main/java/module-info.java @@ -0,0 +1,36 @@ +module org.jboss.weld.spi { + requires transitive org.jboss.weld.api; + requires static java.naming; + requires static java.desktop; + requires static jakarta.cdi.el; + requires static jakarta.el; + requires static jakarta.persistence; + requires static jakarta.transaction; + requires static jakarta.servlet; + requires static jakarta.validation; + requires static jakarta.ejb; + + exports org.jboss.weld.bootstrap.api; + exports org.jboss.weld.bootstrap.api.helpers; + exports org.jboss.weld.bootstrap.spi; + exports org.jboss.weld.bootstrap.spi.helpers; + exports org.jboss.weld.configuration.spi; + exports org.jboss.weld.configuration.spi.helpers; + exports org.jboss.weld.construction.api; + exports org.jboss.weld.ejb.api; + exports org.jboss.weld.ejb.spi; + exports org.jboss.weld.ejb.spi.helpers; + exports org.jboss.weld.injection.spi; + exports org.jboss.weld.injection.spi.helpers; + exports org.jboss.weld.manager.api; + exports org.jboss.weld.resources.spi; + exports org.jboss.weld.resources.spi.helpers; + exports org.jboss.weld.security.spi; + exports org.jboss.weld.serialization.spi; + exports org.jboss.weld.serialization.spi.helpers; + exports org.jboss.weld.servlet.api; + exports org.jboss.weld.servlet.api.helpers; + exports org.jboss.weld.servlet.spi; + exports org.jboss.weld.servlet.spi.helpers; + exports org.jboss.weld.transaction.spi; +} diff --git a/weld/src/main/java/module-info.java b/weld/src/main/java/module-info.java new file mode 100644 index 00000000..4e77516f --- /dev/null +++ b/weld/src/main/java/module-info.java @@ -0,0 +1,18 @@ +module org.jboss.weld.api { + requires transitive jakarta.cdi; + requires static jakarta.servlet; + + exports org.jboss.weld.bootstrap.event; + exports org.jboss.weld.context; + exports org.jboss.weld.context.activator; + exports org.jboss.weld.context.api; + exports org.jboss.weld.context.bound; + exports org.jboss.weld.context.ejb; + exports org.jboss.weld.context.http; + exports org.jboss.weld.context.unbound; + exports org.jboss.weld.events; + exports org.jboss.weld.inject; + exports org.jboss.weld.interceptor; + exports org.jboss.weld.invoke; + exports org.jboss.weld.proxy; +} From 5132ae6d3768f4938e36b31539e1ae20634fe009 Mon Sep 17 00:00:00 2001 From: Matej Novotny Date: Tue, 28 Jul 2026 14:35:05 +0200 Subject: [PATCH 2/3] Add ModuleAccessForwarder SPI for JPMS access forwarding --- .../weld/bootstrap/api/CDI11Bootstrap.java | 23 ++++++++++ .../bootstrap/api/ModuleAccessForwarder.java | 42 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/CDI11Bootstrap.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/CDI11Bootstrap.java index a0aba400..40673060 100644 --- a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/CDI11Bootstrap.java +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/CDI11Bootstrap.java @@ -194,4 +194,27 @@ public interface CDI11Bootstrap extends Bootstrap { * */ Bootstrap startContainer(String contextId, Environment environment, Deployment deployment); + + /** + * Sets a callback for JPMS module access forwarding. When Weld runs on + * the module path, the entry-point module (SE or Servlet) provides a + * forwarder that relays {@code Module.addOpens()} calls so that the + * core module can access user bean packages. + * + *

+ * The forwarder must be a lambda defined in the entry-point module + * (not the core module) so that the JVM sees the correct caller for + * the {@code addOpens} permission check. + *

+ * + *

+ * When running on the classpath (unnamed module), calling this + * method is unnecessary — the forwarder is never invoked. + *

+ * + * @param forwarder the forwarding callback + */ + default void setModuleAccessForwarder(ModuleAccessForwarder forwarder) { + // no-op by default — overridden in WeldBootstrap + } } \ No newline at end of file diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java new file mode 100644 index 00000000..fe191a22 --- /dev/null +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java @@ -0,0 +1,42 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2026, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jboss.weld.bootstrap.api; + +/** + * Callback for forwarding JPMS module access from an entry-point module + * (SE or Servlet) to the core module. The entry-point module creates a + * lambda that calls {@link Module#addOpens(String, Module)}, and core + * invokes it lazily before reflective access to user bean packages. + * + *

+ * The callback must be defined (as a lambda or method reference) in the + * entry-point module so that the JVM's stack-walking check for + * {@code addOpens} sees the correct caller module. + *

+ */ +@FunctionalInterface +public interface ModuleAccessForwarder { + + /** + * Forward access from the source module's package to the target module. + * + * @param sourceModule the module that owns the package to be opened + * @param packageName the package name to open + * @param targetModule the module that needs access + */ + void forwardAccess(Module sourceModule, String packageName, Module targetModule); +} From 660b05e5c4418d2ec25226ce8efb2ae7c294bb5a Mon Sep 17 00:00:00 2001 From: Matej Novotny Date: Wed, 29 Jul 2026 17:48:56 +0200 Subject: [PATCH 3/3] Add SPDX license headers to new files --- weld-spi/src/main/java/module-info.java | 4 ++++ .../bootstrap/api/ModuleAccessForwarder.java | 16 ++-------------- weld/src/main/java/module-info.java | 4 ++++ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/weld-spi/src/main/java/module-info.java b/weld-spi/src/main/java/module-info.java index 1f438ad4..4f52c90c 100644 --- a/weld-spi/src/main/java/module-info.java +++ b/weld-spi/src/main/java/module-info.java @@ -1,3 +1,7 @@ +/* + * Copyright The Weld Authors + * SPDX-License-Identifier: Apache-2.0 + */ module org.jboss.weld.spi { requires transitive org.jboss.weld.api; requires static java.naming; diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java index fe191a22..209fe008 100644 --- a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/ModuleAccessForwarder.java @@ -1,18 +1,6 @@ /* - * JBoss, Home of Professional Open Source - * Copyright 2026, Red Hat, Inc., and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright The Weld Authors + * SPDX-License-Identifier: Apache-2.0 */ package org.jboss.weld.bootstrap.api; diff --git a/weld/src/main/java/module-info.java b/weld/src/main/java/module-info.java index 4e77516f..ef220d93 100644 --- a/weld/src/main/java/module-info.java +++ b/weld/src/main/java/module-info.java @@ -1,3 +1,7 @@ +/* + * Copyright The Weld Authors + * SPDX-License-Identifier: Apache-2.0 + */ module org.jboss.weld.api { requires transitive jakarta.cdi; requires static jakarta.servlet;