You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/05/24 23:45:15 UTC

[groovy] branch GROOVY-9566 created (now 328d76b)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch GROOVY-9566
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at 328d76b  GROOVY-9566: Default import for Proxy is wrong

This branch includes the following new commits:

     new 328d76b  GROOVY-9566: Default import for Proxy is wrong

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[groovy] 01/01: GROOVY-9566: Default import for Proxy is wrong

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY-9566
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 328d76b87ab420b1ec057445435eb4ed33085182
Author: Daniel Sun <su...@apache.org>
AuthorDate: Mon May 25 07:44:58 2020 +0800

    GROOVY-9566: Default import for Proxy is wrong
---
 .../org/codehaus/groovy/vmplugin/v9/Java9.java     |  4 +--
 src/test/groovy/bugs/Groovy9566.groovy             | 32 ++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
index ebd08f3..fee0fdb 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -93,8 +93,6 @@ public class Java9 extends Java8 {
 
         Map<String, Set<String>> result = new LinkedHashMap<>(2048);
         try (GroovyClassLoader gcl = new GroovyClassLoader(this.getClass().getClassLoader())) {
-            result.putAll(doFindClasses(URI.create("jrt:/modules/java.base/"), "java", javaPns));
-
             URI gsLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.lang.GroovySystem")).toURI();
             result.putAll(doFindClasses(gsLocation, "groovy", groovyPns));
 
@@ -104,6 +102,8 @@ public class Java9 extends Java8 {
             if (!gsLocation.equals(giLocation)) {
                 result.putAll(doFindClasses(giLocation, "groovy", groovyPns));
             }
+
+            result.putAll(doFindClasses(URI.create("jrt:/modules/java.base/"), "java", javaPns));
         } catch (Exception ignore) {
             if (LOGGER.isLoggable(Level.FINEST)) {
                 LOGGER.finest("[WARNING] Failed to find default imported classes:\n" + DefaultGroovyMethods.asString(ignore));
diff --git a/src/test/groovy/bugs/Groovy9566.groovy b/src/test/groovy/bugs/Groovy9566.groovy
new file mode 100644
index 0000000..8ab0156
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy9566.groovy
@@ -0,0 +1,32 @@
+/*
+ *  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 groovy.bugs
+
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy9566 {
+    @Test
+    void testDefaultImportsWithSameClassName() {
+        assertScript '''
+            assert Proxy == java.net.Proxy
+        '''
+    }
+}