From e70a3b4dd973a9a8dc7a77c61900304fd5512e48 Mon Sep 17 00:00:00 2001 From: Peter Ivanov Date: Thu, 7 Feb 2019 14:59:36 +0300 Subject: [PATCH] IGNITE-11153 Support Java 11 for control.sh & ignitevisorcmd.sh: remove odd --add-modules for java.xml.bind (#6017) --- bin/control.bat | 46 +++++++++++++++++++++++++++++----------- bin/control.sh | 42 +++++++++++++++++++++++++++--------- bin/ignitevisorcmd.bat | 48 ++++++++++++++++++++++++++++++------------ bin/ignitevisorcmd.sh | 36 ++++++++++++++++++++++++------- 4 files changed, 129 insertions(+), 43 deletions(-) diff --git a/bin/control.bat b/bin/control.bat index d6f97984e2133..7756f128d42c5 100644 --- a/bin/control.bat +++ b/bin/control.bat @@ -49,10 +49,10 @@ for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do ( ) :LoopEscape -set var=%var:~14% -set var=%var:"=% -for /f "tokens=1,2 delims=." %%a in ("%var%") do set MAJOR_JAVA_VER=%%a & set MINOR_JAVA_VER=%%b +for /f "tokens=1-3 delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c +set JAVA_VER_STR=%JAVA_VER_STR:"=% +for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER% if %MAJOR_JAVA_VER% LSS 8 ( @@ -60,14 +60,7 @@ if %MAJOR_JAVA_VER% LSS 8 ( echo The version of JAVA installed in %JAVA_HOME% is incorrect. echo Please point JAVA_HOME variable to installation of JDK 1.8 or later. echo You can also download latest JDK at http://java.com/download. - goto error_finish -) - -if %MAJOR_JAVA_VER% GTR 9 ( - echo %0, WARNING: - echo The version of JAVA installed in %JAVA_HOME% was not tested with Apache Ignite. - echo Run it on your own risk or point JAVA_HOME variable to installation of JDK 1.8 or JDK 9. - echo You can also download latest JDK at http://java.com/download. + goto error_finish ) :: Check IGNITE_HOME. @@ -220,7 +213,36 @@ if "%MAIN_CLASS%" == "" set MAIN_CLASS=org.apache.ignite.internal.commandline.Co :: :: Final JVM_OPTS for Java 9+ compatibility :: -if %MAJOR_JAVA_VER% GEQ 9 set JVM_OPTS=--add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-modules java.xml.bind %JVM_OPTS% +if %MAJOR_JAVA_VER% == 8 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% GEQ 9 if %MAJOR_JAVA_VER% LSS 11 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + --add-modules=java.transaction ^ + --add-modules=java.xml.bind ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% == 11 ( + set JVM_OPTS= ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + %JVM_OPTS% +) if "%INTERACTIVE%" == "1" ( "%JAVA_HOME%\bin\java.exe" %JVM_OPTS% %QUIET% %RESTART_SUCCESS_OPT% %JMX_MON% ^ diff --git a/bin/control.sh b/bin/control.sh index 7f84696831c50..a883bc879b738 100755 --- a/bin/control.sh +++ b/bin/control.sh @@ -140,16 +140,38 @@ fi # JVM_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787 ${JVM_OPTS}" # -# Final JVM_OPTS for Java 9 compatibility -# -${JAVA_HOME}/bin/java -version 2>&1 | grep -qE 'java version "9.*"' && { -JVM_OPTS="--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ - --add-exports java.base/sun.nio.ch=ALL-UNNAMED \ - --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ - --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ - --add-modules java.xml.bind \ - ${JVM_OPTS}" -} || true +# Final JVM_OPTS for Java 9+ compatibility +# +javaMajorVersion "${JAVA_HOME}/bin/java" + +if [ $version -eq 8 ] ; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + ${JVM_OPTS}" + +elif [ $version -gt 8 ] && [ $version -lt 11 ]; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + --add-modules=java.transaction \ + --add-modules=java.xml.bind \ + ${JVM_OPTS}" + +elif [ $version -eq 11 ] ; then + JVM_OPTS="\ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + ${JVM_OPTS}" +fi ERRORCODE="-1" diff --git a/bin/ignitevisorcmd.bat b/bin/ignitevisorcmd.bat index 82238c2d38858..46645b8407f0b 100644 --- a/bin/ignitevisorcmd.bat +++ b/bin/ignitevisorcmd.bat @@ -49,25 +49,18 @@ for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do ( ) :LoopEscape -set var=%var:~14% -set var=%var:"=% -for /f "tokens=1,2 delims=." %%a in ("%var%") do set MAJOR_JAVA_VER=%%a & set MINOR_JAVA_VER=%%b +for /f "tokens=1-3 delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c +set JAVA_VER_STR=%JAVA_VER_STR:"=% +for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER% if %MAJOR_JAVA_VER% LSS 8 ( echo %0, ERROR: - echo The %MAJOR_JAVA_VER% version of JAVA installed in %JAVA_HOME% is incorrect. + echo The version of JAVA installed in %JAVA_HOME% is incorrect. echo Please point JAVA_HOME variable to installation of JDK 1.8 or later. echo You can also download latest JDK at http://java.com/download. - goto error_finish -) - -if %MAJOR_JAVA_VER% GTR 9 ( - echo %0, WARNING: - echo The %MAJOR_JAVA_VER% version of JAVA installed in %JAVA_HOME% was not tested with Apache Ignite. - echo Run it on your own risk or point JAVA_HOME variable to installation of JDK 1.8 or JDK 9. - echo You can also download latest JDK at http://java.com/download. + goto error_finish ) :: Check IGNITE_HOME. @@ -164,7 +157,36 @@ if "%ARGS%" == "" set ARGS=%* :: :: Final JVM_OPTS for Java 9+ compatibility :: -if %MAJOR_JAVA_VER% GEQ 9 set JVM_OPTS=--add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-modules java.xml.bind %JVM_OPTS% +if %MAJOR_JAVA_VER% == 8 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% GEQ 9 if %MAJOR_JAVA_VER% LSS 11 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + --add-modules=java.transaction ^ + --add-modules=java.xml.bind ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% == 11 ( + set JVM_OPTS= ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + %JVM_OPTS% +) :: :: Starts Visor console. diff --git a/bin/ignitevisorcmd.sh b/bin/ignitevisorcmd.sh index 1fcc127b4caf0..077f051fa53b0 100755 --- a/bin/ignitevisorcmd.sh +++ b/bin/ignitevisorcmd.sh @@ -106,17 +106,37 @@ function restoreSttySettings() { trap restoreSttySettings INT # -# Final JVM_OPTS for Java 9 compatibility +# Final JVM_OPTS for Java 9+ compatibility # javaMajorVersion "${JAVA_HOME}/bin/java" -if [ $version -gt 8 ]; then - JVM_OPTS="--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ - --add-exports java.base/sun.nio.ch=ALL-UNNAMED \ - --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ - --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ - --add-modules java.xml.bind \ - ${JVM_OPTS}" +if [ $version -eq 8 ] ; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + ${JVM_OPTS}" + +elif [ $version -gt 8 ] && [ $version -lt 11 ]; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + --add-modules=java.transaction \ + --add-modules=java.xml.bind \ + ${JVM_OPTS}" + +elif [ $version -eq 11 ] ; then + JVM_OPTS="\ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + ${JVM_OPTS}" fi #