Suppress JDK 25 warnings

This commit is contained in:
Eugene Yokota 2025-09-28 04:06:37 -04:00
parent b52944cd3c
commit 51aa789346
3 changed files with 39 additions and 6 deletions

View File

@ -33,7 +33,9 @@ jobs:
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: "8"
java-version: |
25
8
cache: sbt
- uses: sbt/setup-sbt@v1
with:
@ -60,7 +62,6 @@ jobs:
sbt -Dsbt.build.version=$TEST_SBT_VER rpm:packageBin debian:packageBin
sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
cd citest && ./test.sh
$HOME/bin/jabba install $JDK11 && exec $HOME/bin/jabba which --home $JDK11
java -Xmx32m -version
./test.sh
- name: Client test (macOS)
@ -91,4 +92,5 @@ jobs:
sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
cd citest
./test.bat
java -Xmx32m -version
test3/test3.bat

View File

@ -39,6 +39,7 @@ set sbt_args_color=
set sbt_args_no_colors=
set sbt_args_no_global=
set sbt_args_no_share=
set sbt_args_no_hide_jdk_warnings=
set sbt_args_sbt_jar=
set sbt_args_ivy=
set sbt_args_supershell=
@ -231,6 +232,14 @@ if defined _no_server_arg (
goto args_loop
)
if "%~0" == "--no-hide-jdk-warnings" set _no_hide_jdk_warnings=true
if defined _no_hide_jdk_warnings (
set _no_hide_jdk_warnings=
set sbt_args_no_hide_jdk_warnings=1
goto args_loop
)
if "%~0" == "-no-global" set _no_global_arg=true
if "%~0" == "--no-global" set _no_global_arg=true
@ -677,6 +686,13 @@ if defined sbt_args_no_server (
set _SBT_OPTS=-Dsbt.io.virtual=false -Dsbt.server.autostart=false !_SBT_OPTS!
)
if not defined sbt_args_no_hide_jdk_warnings (
if /I !JAVA_VERSION! EQU 25 (
call :addJava --sun-misc-unsafe-memory-access=allow
call :addJava --enable-native-access=ALL-UNNAMED
)
)
rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS
if !sbt_args_print_sbt_version! equ 1 (

23
sbt
View File

@ -28,6 +28,7 @@ declare sbtn_command="$SBTN_CMD"
declare sbtn_version="1.11.6"
declare use_colors=1
declare is_this_dir_sbt=""
declare hide_jdk_warnings=1
### ------------------------------- ###
### Helper methods for BASH scripts ###
@ -85,7 +86,7 @@ CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi)
# windows style paths.
cygwinpath() {
local file="$1"
if [[ "$CYGWIN_FLAG" == "true" ]]; then #"
if [[ "$CYGWIN_FLAG" == "true" ]]; then
echo $(cygpath -w $file)
else
echo $file
@ -114,7 +115,7 @@ echoerr_error () {
echoerr -e "[${RED}error${NC}] $@"
else
echoerr "[error] $@"
fi
fi #"
}
vlog () {
[[ $sbt_verbose || $sbt_debug ]] && echoerr "$@"
@ -347,6 +348,18 @@ addSbtScriptProperty () {
fi
}
addJdkWorkaround () {
local is_25="$(expr $java_version "=" 25)"
if [[ "$hide_jdk_warnings" == "0" ]]; then
:
else
if [[ "$is_25" == "1" ]]; then
addJava "--sun-misc-unsafe-memory-access=allow"
addJava "--enable-native-access=ALL-UNNAMED"
fi
fi
}
require_arg () {
local type="$1"
local opt="$2"
@ -532,7 +545,7 @@ run() {
copyRt
# If we're in cygwin, we should use the windows config, and terminal hacks
if [[ "$CYGWIN_FLAG" == "true" ]]; then #"
if [[ "$CYGWIN_FLAG" == "true" ]]; then
stty -icanon min 1 -echo > /dev/null 2>&1
addJava "-Djline.terminal=jline.UnixTerminal"
addJava "-Dsbt.cygwin=true"
@ -572,7 +585,7 @@ run() {
exit_code=$?
# Clean up the terminal from cygwin hacks.
if [[ "$CYGWIN_FLAG" == "true" ]]; then #"
if [[ "$CYGWIN_FLAG" == "true" ]]; then
stty icanon echo > /dev/null 2>&1
fi
exit $exit_code
@ -705,6 +718,7 @@ process_args () {
-client|--client) use_sbtn=1 && shift ;;
--server) use_sbtn=0 && shift ;;
--jvm-client) use_sbtn=0 && use_jvm_client=1 && addSbt "--client" && shift ;;
--no-hide-jdk-warnings) hide_jdk_warnings=0 && shift ;;
-mem|--mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;;
-jvm-debug|--jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
@ -867,6 +881,7 @@ else
vlog "[process_args] java_version = '$java_version'"
addDefaultMemory
addSbtScriptProperty
addJdkWorkaround
set -- "${residual_args[@]}"
argumentCount=$#
run