From a5d70cfa689eabc5982cd582f7f130730f63a162 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Mar 2017 16:35:02 +0300 Subject: [PATCH] Support running Kotlin compiler CLI on Java 9 on Unix Workaround IDEA-170005, IDEA-170494 and similar issues by opening the required packages from java.base to the unnamed module #KT-14988 In Progress --- build.xml | 3 +++ compiler/cli/bin/kotlinc | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/build.xml b/build.xml index fac2b7730b8..073242d951d 100644 --- a/build.xml +++ b/build.xml @@ -600,6 +600,9 @@ + + + diff --git a/compiler/cli/bin/kotlinc b/compiler/cli/bin/kotlinc index 9eacfbb6a5c..ee34b6cf93e 100755 --- a/compiler/cli/bin/kotlinc +++ b/compiler/cli/bin/kotlinc @@ -67,6 +67,15 @@ then else [ -n "$KOTLIN_COMPILER" ] || KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler java_args=("${java_args[@]}" "-noverify") + + if [[ -n $(command -v head) && -n $(command -v tail) && $($JAVACMD -version 2>&1 | head -2 | tail -1) =~ build\ 9 ]]; then + java_args=("${java_args[@]}" \ + "--add-opens" "java.base/java.lang=ALL-UNNAMED" \ + "--add-opens" "java.base/java.util=ALL-UNNAMED" \ + "--add-opens" "java.base/java.util.concurrent.atomic=ALL-UNNAMED" \ + "--add-opens" "java.base/jdk.internal.misc=ALL-UNNAMED") + fi + kotlin_app=("${KOTLIN_HOME}/lib/kotlin-preloader.jar" "org.jetbrains.kotlin.preloading.Preloader" "-cp" "${KOTLIN_HOME}/lib/kotlin-compiler.jar" $KOTLIN_COMPILER) fi