Fix NoClassDefFoundError when using Java9 further

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

Branch: refs/heads/GROOVY_2_5_X
Commit: 809a84782e7e828c6c05c1c26b5b540f249b15cf
Parents: 8065943
Author: sunlan <sun...@apache.org>
Authored: Fri Sep 22 16:22:34 2017 +0800
Committer: Paul King <pa...@asert.com.au>
Committed: Thu Jul 12 22:37:27 2018 +1000

----------------------------------------------------------------------
 src/bin/startGroovy     | 7 +++++--
 src/bin/startGroovy.bat | 7 ++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/809a8478/src/bin/startGroovy
----------------------------------------------------------------------
diff --git a/src/bin/startGroovy b/src/bin/startGroovy
index ee78b68..bd40317 100644
--- a/src/bin/startGroovy
+++ b/src/bin/startGroovy
@@ -221,8 +221,6 @@ if $darwin; then
     JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GROOVY_APP_NAME 
-Xdock:icon=$GROOVY_HOME/lib/groovy.icns"
 fi
 
-JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM"
-
 # For Cygwin, switch paths to Windows format before running java
 if $cygwin ; then
     GROOVY_HOME=`cygpath --mixed "$GROOVY_HOME"`
@@ -280,6 +278,11 @@ if $cygwin ; then
 fi
 
 startGroovy ( ) {
+    JAVA_VERSION=`"$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}' 
| cut -d "_" -f1`
+    if [[ "$JAVA_VERSION" > "1.8.0" ]]; then
+        JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM"
+    fi
+
     CLASS=$1
     shift
     # Start the Profiler or the JVM

http://git-wip-us.apache.org/repos/asf/groovy/blob/809a8478/src/bin/startGroovy.bat
----------------------------------------------------------------------
diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat
index 6b67567..3e7d385 100644
--- a/src/bin/startGroovy.bat
+++ b/src/bin/startGroovy.bat
@@ -266,7 +266,12 @@ if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% 
-Dtools.jar="%TOOLS_JAR
 set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%"
 set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%"
 
-set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM
+for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
+  SET JAVA_VERSION=%%g
+)
+for /f "useback tokens=*" %%a in ('%JAVA_VERSION%') do set JAVA_VERSION=%%~a
+set JAVA_VERSION=%JAVA_VERSION:~0,5%
+if "%JAVA_VERSION%" gtr "1.8.0" set JAVA_OPTS=%JAVA_OPTS% --add-modules 
ALL-SYSTEM
 
 if exist "%USERPROFILE%/.groovy/postinit.bat" call 
"%USERPROFILE%/.groovy/postinit.bat"
 

Reply via email to