desruisseaux commented on code in PR #11029:
URL: https://github.com/apache/maven/pull/11029#discussion_r3499833113


##########
impl/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java:
##########
@@ -364,4 +373,65 @@ private static Object getId(ClassLoader classLoader) {
         }
         return classLoader;
     }
+
+    private static final String MODULE_ACCESS_DESCRIPTOR = 
"META-INF/maven/module-access";
+
+    private void applyModuleAccessDescriptors(ClassRealm classRealm) {

Review Comment:
   Do we have a documentation somewhere of what this code is doing? It seems to 
open or export packages of a module, but I'm not sure in which direction:
   
   * If `META-INF/maven/module-access` exports package from the module that we 
are loading to other modules, why not using the standard `module-info` 
mechanism?
   * If `META-INF/maven/module-access` exports package from another module to 
the module that we are loading, it breaks encapsulation principles. Like 
allowing class _A_ to decide what is private inside class _B_.



##########
impl/maven-classworlds/src/test/java/org/codehaus/plexus/classworlds/realm/ClassRealmImplTest.java:
##########
@@ -0,0 +1,482 @@
+/*
+ * 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.codehaus.plexus.classworlds.realm;
+
+/*
+ * Copyright 2001-2006 Codehaus Foundation.
+ *
+ * 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.
+ */
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.codehaus.plexus.classworlds.AbstractClassWorldsTestCase;
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class ClassRealmImplTest extends AbstractClassWorldsTestCase {
+    private ClassWorld world;
+
+    @BeforeEach
+    public void setUp() {
+        this.world = new ClassWorld();
+    }
+
+    @AfterEach
+    public void tearDown() {
+        this.world = null;
+    }
+
+    @Test
+    void testNewRealm() throws Exception {
+        ClassRealm realm = this.world.newRealm("foo");
+
+        assertNotNull(realm);
+
+        assertSame(this.world, realm.getWorld());
+
+        assertEquals("foo", realm.getId());
+    }
+
+    @Test
+    void testLocateSourceRealmNoImports() {
+        ClassRealm realm = new ClassRealm(this.world, "foo", null);
+
+        assertSame(null, realm.getImportClassLoader("com.werken.Stuff"));
+    }
+
+    @Test
+    void testLocateSourceRealmSimpleImport() throws Exception {
+        ClassRealm mainRealm = this.world.newRealm("main");
+
+        ClassRealm werkflowRealm = this.world.newRealm("werkflow");
+
+        mainRealm.importFrom("werkflow", "com.werken.werkflow");
+
+        assertSame(werkflowRealm, 
mainRealm.getImportClassLoader("com.werken.werkflow.WerkflowEngine"));
+

Review Comment:
   It is not very important, but all those blank lines consume a large number 
of space for no apparent reason.



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