diff --git a/java/config/kotlin.go b/java/config/kotlin.go index fd8e3dbe9..6cb61f306 100644 --- a/java/config/kotlin.go +++ b/java/config/kotlin.go @@ -35,11 +35,16 @@ func init() { pctx.SourcePathVariable("KotlinAnnotationJar", "external/kotlinc/lib/annotations-13.0.jar") pctx.SourcePathVariable("KotlinStdlibJar", KotlinStdlibJar) - // These flags silence "Illegal reflective access" warnings when running kotlinc in OpenJDK9 - pctx.StaticVariable("KotlincSuppressJDK9Warnings", strings.Join([]string{ + // These flags silence "Illegal reflective access" warnings when running kapt in OpenJDK9+ + pctx.StaticVariable("KaptSuppressJDK9Warnings", strings.Join([]string{ "-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", "-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", "-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED", "-J--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED", }, " ")) + + // These flags silence "Illegal reflective access" warnings when running kotlinc in OpenJDK9+ + pctx.StaticVariable("KotlincSuppressJDK9Warnings", strings.Join([]string{ + "-J--add-opens=java.base/java.util=ALL-UNNAMED", // https://youtrack.jetbrains.com/issue/KT-43704 + }, " ")) } diff --git a/java/kotlin.go b/java/kotlin.go index 2960f819d..3a6fc0f48 100644 --- a/java/kotlin.go +++ b/java/kotlin.go @@ -34,8 +34,9 @@ var kotlinc = pctx.AndroidRemoteStaticRule("kotlinc", android.RemoteRuleSupports `${config.GenKotlinBuildFileCmd} --classpath "$classpath" --name "$name"` + ` --out_dir "$classesDir" --srcs "$out.rsp" --srcs "$srcJarDir/list"` + ` $commonSrcFilesArg --out "$kotlinBuildFile" && ` + - `${config.KotlincCmd} ${config.JavacHeapFlags} $kotlincFlags ` + - `-jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile -kotlin-home $emptyDir && ` + + `${config.KotlincCmd} ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} ` + + `$kotlincFlags -jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile ` + + `-kotlin-home $emptyDir && ` + `${config.SoongZipCmd} -jar -o $out -C $classesDir -D $classesDir && ` + `rm -rf "$srcJarDir"`, CommandDeps: []string{ @@ -123,8 +124,8 @@ var kapt = pctx.AndroidRemoteStaticRule("kapt", android.RemoteRuleSupports{Goma: `${config.GenKotlinBuildFileCmd} --classpath "$classpath" --name "$name"` + ` --srcs "$out.rsp" --srcs "$srcJarDir/list"` + ` $commonSrcFilesArg --out "$kotlinBuildFile" && ` + - `${config.KotlincCmd} ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} $kotlincFlags ` + - `-Xplugin=${config.KotlinKaptJar} ` + + `${config.KotlincCmd} ${config.KaptSuppressJDK9Warnings} ${config.KotlincSuppressJDK9Warnings} ` + + `${config.JavacHeapFlags} $kotlincFlags -Xplugin=${config.KotlinKaptJar} ` + `-P plugin:org.jetbrains.kotlin.kapt3:sources=$kaptDir/sources ` + `-P plugin:org.jetbrains.kotlin.kapt3:classes=$kaptDir/classes ` + `-P plugin:org.jetbrains.kotlin.kapt3:stubs=$kaptDir/stubs ` +