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:15:40 UTC
[groovy] branch master updated: 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 master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 850fee6 GROOVY-9566: Default import for Proxy is wrong (#1256)
850fee6 is described below
commit 850fee6145153ada724036d5e1fb7d75a327fe5d
Author: Daniel.Sun <su...@apache.org>
AuthorDate: Mon May 25 08:15:30 2020 +0800
GROOVY-9566: Default import for Proxy is wrong (#1256)
---
.../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
+ '''
+ }
+}