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/30 15:36:12 UTC
[groovy] branch GROOVY_3_0_X updated: Ensure Java default imports
will be included
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
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 3f3f0c7 Ensure Java default imports will be included
3f3f0c7 is described below
commit 3f3f0c7d2557f71e46bcdd84de2469c7b83950c8
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat May 30 23:27:56 2020 +0800
Ensure Java default imports will be included
(cherry picked from commit 079b677acd8fd24607e4ed395d60833f9f79ba72)
---
.../org/codehaus/groovy/vmplugin/v9/Java9.java | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 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 f875fa9..2ac8ef3 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -83,17 +83,19 @@ public class Java9 extends Java8 {
Map<String, Set<String>> result = new LinkedHashMap<>(2048);
try (GroovyClassLoader gcl = new GroovyClassLoader(this.getClass().getClassLoader())) {
- URI gsLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.lang.GroovySystem")).toURI();
- result.putAll(doFindClasses(gsLocation, "groovy", groovyPns));
-
- // in production environment, groovy-core classes, e.g. `GroovySystem`(java class) and `GrapeIvy`(groovy class) are all packaged in the groovy-core jar file,
- // but in Groovy development environment, groovy-core classes are distributed in different directories
- URI giLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.grape.GrapeIvy")).toURI();
- if (!gsLocation.equals(giLocation)) {
- result.putAll(doFindClasses(giLocation, "groovy", groovyPns));
+ try {
+ URI gsLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.lang.GroovySystem")).toURI();
+ result.putAll(doFindClasses(gsLocation, "groovy", groovyPns));
+
+ // in production environment, groovy-core classes, e.g. `GroovySystem`(java class) and `GrapeIvy`(groovy class) are all packaged in the groovy-core jar file,
+ // but in Groovy development environment, groovy-core classes are distributed in different directories
+ URI giLocation = DefaultGroovyMethods.getLocation(gcl.loadClass("groovy.grape.GrapeIvy")).toURI();
+ if (!gsLocation.equals(giLocation)) {
+ result.putAll(doFindClasses(giLocation, "groovy", groovyPns));
+ }
+ } finally {
+ result.putAll(doFindClasses(URI.create("jrt:/modules/java.base/"), "java", javaPns));
}
-
- 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));