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/25 00:17:58 UTC
[groovy] 03/03: GROOVY-9566: Default import for Proxy is wrong
(#1256)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 94d039d505835d9564c52d2a263b65b0456f2d5b
Author: Daniel.Sun <su...@apache.org>
AuthorDate: Mon May 25 08:15:30 2020 +0800
GROOVY-9566: Default import for Proxy is wrong (#1256)
(cherry picked from commit 850fee6145153ada724036d5e1fb7d75a327fe5d)
---
.../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 e635157..09b7b71 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -82,8 +82,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));
@@ -93,6 +91,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
+ '''
+ }
+}