gnodet-bot commented on code in PR #13625:
URL: https://github.com/apache/maven/pull/13625#discussion_r4326388142


##########
api/maven-api-core/src/main/java/org/apache/maven/api/Realm.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.maven.api;
+
+import java.util.Optional;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.services.Lookup;
+
+/**
+ * A runtime scope that bundles classloading with scoped component discovery.
+ * Used uniformly for sessions, projects, and plugins — the difference is
+ * what the {@link #lookup()} sees, not the type.
+ *
+ * @since 4.1.0
+ */
+@Experimental
+public interface Realm {
+
+    /**
+     * Returns the classloader for this realm.
+     *
+     * @return the classloader, never {@code null}
+     */
+    @Nonnull
+    ClassLoader classLoader();
+
+    /**
+     * Returns the JPMS module layer when this realm runs in a modular 
configuration.
+     *
+     * @return the module layer, or an empty optional for a classpath-based 
realm
+     */
+    @Nonnull
+    Optional<ModuleLayer> moduleLayer();
+
+    /**
+     * Returns component lookup scoped to this realm's visibility.
+     *
+     * @return the realm-scoped component lookup, never {@code null}
+     */

Review Comment:
   💡 The Javadoc says "Returns component lookup scoped to this realm's 
visibility" — but the actual scoping mechanism is TCCL-switching only. 
`DefaultRealm` wraps the **global** `Lookup` injected at construction; 
`RealmLookup` switches the thread context classloader to the plugin realm 
before delegating, but whether Sisu restricts returned components to those 
visible in that realm is a container-internal behavior, not a contract of this 
API.
   
   Consider softening the claim to describe what the implementation actually 
guarantees:
   
   ```suggestion
       /**
        * Returns component lookup that delegates to the container with this 
realm's
        * classloader set as the thread context classloader. The visibility of 
discovered
        * components depends on the container's TCCL-based filtering behavior.
        *
        * @return the realm-aware component lookup, never {@code null}
        */
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to