Skip to content

Commit

Permalink
IGNITE-11153 Support Java 11 for control.sh & ignitevisorcmd.sh: remo…
Browse files Browse the repository at this point in the history
…ve odd --add-modules for java.xml.bind (apache#6017)
  • Loading branch information
vveider authored and dspavlov committed Feb 7, 2019
1 parent ba48c3f commit e70a3b4
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 43 deletions.
46 changes: 34 additions & 12 deletions bin/control.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
Expand Down Expand Up @@ -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% ^
Expand Down
42 changes: 32 additions & 10 deletions bin/control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
48 changes: 35 additions & 13 deletions bin/ignitevisorcmd.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
36 changes: 28 additions & 8 deletions bin/ignitevisorcmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down

0 comments on commit e70a3b4

Please sign in to comment.