CLI: do not pass -noverify to java process starting from JDK 13

#KT-44232 Fixed
This commit is contained in:
Alexander Udalov
2021-01-07 22:20:19 +01:00
parent 2bbe3db041
commit 2ef4ca4e6e
2 changed files with 52 additions and 12 deletions
+18 -5
View File
@@ -21,6 +21,17 @@ findKotlinHome() {
(cd -P "$(dirname "$source")/.." && pwd)
}
findJavaVersion() {
# Note that this only loads the first component of the version, so "1.8.0_265" -> "1".
# But it's fine because major version is 9 for JDK 9, and so on.
regex='^.*version "([[:digit:]]+).*$'
while read -r line; do
if [[ "$line" =~ $regex ]]; then
echo ${BASH_REMATCH[1]}
fi
done <<< $("${JAVACMD:=java}" -version 2>&1)
}
KOTLIN_HOME="$(findKotlinHome)"
if $cygwin; then
@@ -56,17 +67,19 @@ fi
declare -a kotlin_app
if [ -n "$KOTLIN_RUNNER" ];
then
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_args=("${java_args[@]}" "-noverify")
java_version="$(findJavaVersion)"
if [[ $java_version < 13 ]]; then
java_args=("${java_args[@]}" "-noverify")
fi
declare additional_classpath=""
if [ -n "$KOTLIN_TOOL" ];
then
if [ -n "$KOTLIN_TOOL" ]; then
additional_classpath=":${KOTLIN_HOME}/lib/${KOTLIN_TOOL}"
fi