You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2016/10/02 18:40:01 UTC

groovy git commit: Fix package lookup for jdk9 modular runtime

Repository: groovy
Updated Branches:
  refs/heads/master f93cb30a4 -> 41fb27eb3


Fix package lookup for jdk9 modular runtime


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/41fb27eb
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/41fb27eb
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/41fb27eb

Branch: refs/heads/master
Commit: 41fb27eb31adc9639a9a46b27d4f4ddd775a2efd
Parents: f93cb30
Author: John Wagenleitner <jw...@apache.org>
Authored: Sun Oct 2 10:50:30 2016 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sun Oct 2 11:23:46 2016 -0700

----------------------------------------------------------------------
 .../groovy/tools/shell/util/PackageHelperImpl.groovy     | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/41fb27eb/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/PackageHelperImpl.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/PackageHelperImpl.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/PackageHelperImpl.groovy
index cf0dbf6..16018c8 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/PackageHelperImpl.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/PackageHelperImpl.groovy
@@ -115,7 +115,7 @@ class PackageHelperImpl implements PreferenceChangeListener, PackageHelper {
                 mergeNewPackages(packageNames, url, rootPackages)
             }
         }
-        if (jigsaw) {
+        if (jigsaw || isModularRuntime()) {
             URL jigsawURL = URI.create("jrt:/").toURL()
             Set<String> jigsawPackages = getPackagesAndClassesFromJigsaw(jigsawURL)  { isPackage, name -> isPackage && name }
             mergeNewPackages(jigsawPackages, jigsawURL, rootPackages)
@@ -123,6 +123,15 @@ class PackageHelperImpl implements PreferenceChangeListener, PackageHelper {
         return rootPackages
     }
 
+    // TODO: review after jdk9 is released
+    private static boolean isModularRuntime() {
+        try {
+            return this.classLoader.loadClass('java.lang.reflect.Module', false) != null
+        } catch (e) {
+            return false
+        }
+    }
+
     /**
      * This method returns packages or classes listed from Jigsaw modules.
      * It makes use of a GroovyShell in order to avoid a hard dependency