gnodet commented on code in PR #13490:
URL: https://github.com/apache/maven/pull/13490#discussion_r4268404425


##########
api/maven-api-classworlds/src/main/java/org/apache/maven/api/classworlds/ClassRealm.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * 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.classworlds;
+
+import java.io.Closeable;
+import java.net.URL;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * A class loading realm that provides isolated class loading with controlled 
imports and exports.
+ * <p>
+ * A ClassRealm represents an isolated class loading environment with its own 
classpath
+ * and controlled access to classes from other realms through imports.
+ * </p>
+ *
+ * @since 4.1.0
+ */
+@Experimental
+public interface ClassRealm extends Closeable {
+
+    /**
+     * Returns the unique identifier for this realm.
+     *
+     * @return the realm identifier
+     */
+    @Nonnull
+    String getId();

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Not applicable — the noun-style accessor convention applies to `@Immutable` 
value types only. `ClassWorld` and `ClassRealm` are mutable objects (realms are 
created, disposed, imports added, parent realms changed), so the standard 
`get`-prefixed accessors are correct here.



##########
api/maven-api-classworlds/src/main/java/org/apache/maven/api/classworlds/Strategy.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.classworlds;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * A strategy for defining how classes and resources are located in class 
realms.
+ * <p>
+ * Different strategies can implement different class loading behaviors, such 
as
+ * parent-first, child-first, or custom delegation patterns.
+ * </p>
+ *
+ * @since 4.1.0
+ */
+@Experimental
+public interface Strategy {
+
+    /**
+     * Loads a class using this strategy.
+     *
+     * @param name the fully qualified class name
+     * @return the loaded class
+     * @throws ClassNotFoundException if the class cannot be found
+     */
+    @Nonnull
+    Class<?> loadClass(@Nonnull String name) throws ClassNotFoundException;
+
+    /**
+     * Finds a resource using this strategy.
+     *
+     * @param name the resource name
+     * @return the resource URL, or null if not found
+     */
+    @Nullable
+    URL getResource(@Nonnull String name);
+
+    /**
+     * Finds all resources with the given name using this strategy.
+     *
+     * @param name the resource name
+     * @return an enumeration of resource URLs
+     * @throws IOException if an I/O error occurs
+     */
+    @Nonnull
+    Enumeration<URL> getResources(@Nonnull String name) throws IOException;
+
+    /**
+     * Returns the class realm that this strategy operates on.
+     *
+     * @return the associated class realm
+     */
+    @Nonnull
+    ClassRealm getRealm();

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Not applicable — the noun-style accessor convention applies to `@Immutable` 
value types only. `ClassWorld` and `ClassRealm` are mutable objects (realms are 
created, disposed, imports added, parent realms changed), so the standard 
`get`-prefixed accessors are correct here.



##########
api/maven-api-classworlds/src/main/java/org/apache/maven/api/classworlds/ClassWorldException.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.classworlds;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * Base exception for class world related errors.
+ * <p>
+ * This is the root exception type for all class world operations.
+ * Specific error conditions are represented by subclasses.
+ * </p>
+ *
+ * @since 4.1.0
+ */
+@Experimental
+public class ClassWorldException extends Exception {
+
+    /**
+     * The class world associated with this exception.
+     */
+    private final ClassWorld world;
+
+    /**
+     * Constructs a new ClassWorldException.
+     *
+     * @param world the class world associated with this exception
+     */
+    public ClassWorldException(@Nonnull ClassWorld world) {
+        this.world = world;
+    }
+
+    /**
+     * Constructs a new ClassWorldException with the specified detail message.
+     *
+     * @param world the class world associated with this exception
+     * @param message the detail message
+     */
+    public ClassWorldException(@Nonnull ClassWorld world, @Nullable String 
message) {
+        super(message);
+        this.world = world;
+    }
+
+    /**
+     * Constructs a new ClassWorldException with the specified detail message 
and cause.
+     *
+     * @param world the class world associated with this exception
+     * @param message the detail message
+     * @param cause the cause
+     */
+    public ClassWorldException(@Nonnull ClassWorld world, @Nullable String 
message, @Nullable Throwable cause) {
+        super(message, cause);
+        this.world = world;
+    }
+
+    /**
+     * Constructs a new ClassWorldException with the specified cause.
+     *
+     * @param world the class world associated with this exception
+     * @param cause the cause
+     */
+    public ClassWorldException(@Nonnull ClassWorld world, @Nullable Throwable 
cause) {
+        super(cause);
+        this.world = world;
+    }
+
+    /**
+     * Returns the class world associated with this exception.
+     *
+     * @return the class world
+     */
+    @Nonnull
+    public ClassWorld getWorld() {

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Not applicable — the noun-style accessor convention applies to `@Immutable` 
value types only. `ClassWorld` and `ClassRealm` are mutable objects (realms are 
created, disposed, imports added, parent realms changed), so the standard 
`get`-prefixed accessors are correct here.



##########
api/maven-api-classworlds/src/main/java/org/apache/maven/api/classworlds/NoSuchRealmException.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.classworlds;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Exception thrown when attempting to retrieve a class realm with an 
identifier
+ * that does not exist in the class world.
+ *
+ * @since 4.1.0
+ */
+@Experimental
+public class NoSuchRealmException extends ClassWorldException {
+
+    /**
+     * The missing realm identifier.
+     */
+    private final String id;
+
+    /**
+     * Constructs a new NoSuchRealmException.
+     *
+     * @param world the class world
+     * @param id the missing realm identifier
+     */
+    public NoSuchRealmException(@Nonnull ClassWorld world, @Nonnull String id) 
{
+        super(world, "No such realm: " + id);
+        this.id = id;
+    }
+
+    /**
+     * Returns the missing realm identifier.
+     *
+     * @return the realm identifier
+     */
+    @Nonnull
+    public String getId() {

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Not applicable — the noun-style accessor convention applies to `@Immutable` 
value types only. `ClassWorld` and `ClassRealm` are mutable objects (realms are 
created, disposed, imports added, parent realms changed), so the standard 
`get`-prefixed accessors are correct here.



##########
api/maven-api-classworlds/src/main/java/org/apache/maven/api/classworlds/DuplicateRealmException.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.classworlds;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Exception thrown when attempting to create a class realm with an identifier
+ * that already exists in the class world.
+ *
+ * @since 4.1.0
+ */
+@Experimental
+public class DuplicateRealmException extends ClassWorldException {
+
+    /**
+     * The duplicate realm identifier.
+     */
+    private final String id;
+
+    /**
+     * Constructs a new DuplicateRealmException.
+     *
+     * @param world the class world
+     * @param id the duplicate realm identifier
+     */
+    public DuplicateRealmException(@Nonnull ClassWorld world, @Nonnull String 
id) {
+        super(world, "Duplicate realm: " + id);
+        this.id = id;
+    }
+
+    /**
+     * Returns the duplicate realm identifier.
+     *
+     * @return the realm identifier
+     */
+    @Nonnull
+    public String getId() {

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Not applicable — the noun-style accessor convention applies to `@Immutable` 
value types only. `ClassWorld` and `ClassRealm` are mutable objects (realms are 
created, disposed, imports added, parent realms changed), so the standard 
`get`-prefixed accessors are correct here.



-- 
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