CLI: suppress warning on JDK 9+ with illegal access to ResourceBundle
The underlying issue is tracked in IDEA-248785. #KT-43704 Fixed
This commit is contained in:
@@ -67,13 +67,18 @@ fi
|
||||
|
||||
declare -a kotlin_app
|
||||
|
||||
java_version="$(findJavaVersion)"
|
||||
if [[ $java_version -ge 9 ]]; then
|
||||
# Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785.
|
||||
java_args=("${java_args[@]}" "--add-opens" "java.base/java.util=ALL-UNNAMED")
|
||||
fi
|
||||
|
||||
if [ -n "$KOTLIN_RUNNER" ]; then
|
||||
java_args=("${java_args[@]}" "-Dkotlin.home=${KOTLIN_HOME}")
|
||||
kotlin_app=("${KOTLIN_HOME}/lib/kotlin-runner.jar" "org.jetbrains.kotlin.runner.Main")
|
||||
else
|
||||
[ -n "$KOTLIN_COMPILER" ] || KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
|
||||
java_version="$(findJavaVersion)"
|
||||
if [[ $java_version < 13 ]]; then
|
||||
java_args=("${java_args[@]}" "-noverify")
|
||||
fi
|
||||
|
||||
@@ -40,14 +40,20 @@ shift
|
||||
goto loop
|
||||
:loopend
|
||||
|
||||
if "%_KOTLIN_RUNNER%"=="1" (
|
||||
java %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
call :set_java_version
|
||||
if !_java_major_version! geq 9 (
|
||||
rem Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785.
|
||||
set JAVA_OPTS=!JAVA_OPTS! "--add-opens" "java.base/java.util=ALL-UNNAMED"
|
||||
)
|
||||
|
||||
if "!_KOTLIN_RUNNER!"=="1" (
|
||||
java !JAVA_OPTS! "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
|
||||
org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS%
|
||||
) else (
|
||||
setlocal EnableDelayedExpansion
|
||||
set _ADDITIONAL_CLASSPATH=
|
||||
|
||||
call :set_java_version
|
||||
if !_java_major_version! lss 13 (
|
||||
set JAVA_OPTS=!JAVA_OPTS! "-noverify"
|
||||
)
|
||||
|
||||
@@ -33,7 +33,8 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
|
||||
expectedStdout: String = "",
|
||||
expectedStderr: String = "",
|
||||
expectedExitCode: Int = 0,
|
||||
workDirectory: File? = null
|
||||
workDirectory: File? = null,
|
||||
environment: Map<String, String> = emptyMap(),
|
||||
) {
|
||||
val executableFileName = if (SystemInfo.isWindows) "$executableName.bat" else executableName
|
||||
val launcherFile = File(PathUtil.kotlinPathsForDistDirectory.homePath, "bin/$executableFileName")
|
||||
@@ -43,9 +44,10 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
|
||||
// So, use ProcessBuilder instead.
|
||||
val pb = ProcessBuilder(
|
||||
launcherFile.absolutePath,
|
||||
// In cmd, `=` is delimeter, so we need to surround parameter with quotes.
|
||||
// In cmd, `=` is delimiter, so we need to surround parameter with quotes.
|
||||
*quoteIfNeeded(args)
|
||||
)
|
||||
pb.environment().putAll(environment)
|
||||
pb.directory(workDirectory)
|
||||
val process = pb.start()
|
||||
val stdout =
|
||||
@@ -334,4 +336,17 @@ fun f() : Result<Int> = Result.success(42)
|
||||
)
|
||||
runProcess("kotlin", "-howtorun", "classfile", "test.HelloWorldKt", expectedStdout = "Hello!\n", workDirectory = tmpdir)
|
||||
}
|
||||
|
||||
fun testKotlincJdk15() {
|
||||
val jdk15 = mapOf("JAVA_HOME" to KtTestUtil.getJdk15Home().absolutePath)
|
||||
runProcess(
|
||||
"kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path,
|
||||
environment = jdk15,
|
||||
)
|
||||
|
||||
runProcess(
|
||||
"kotlin", "-e", "listOf('O'.toString() + 'K')",
|
||||
expectedStdout = "[OK]\n", environment = jdk15,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user