rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

Reduce illegal reflective operation warnings when compiling code

Open shs96c opened this issue 4 years ago • 3 comments

Without opening the util package, the following is seen when compiling Kotlin code:

INFO: From Executing genrule //src/main/kotlin/io/bazel/kotlin/plugin/jdeps:jdeps-gen-lib_jar [for host]:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

This is a known issue in kotlin, for some versions of kotlin on some versions of the JDK: https://youtrack.jetbrains.com/issue/KT-43704

The downside with the flag is that it's Java 9+ only, but since Bazel requires Java 11 to run, this seems like a reasonable assertion to make.

shs96c avatar Apr 14 '21 13:04 shs96c

I went to merge this, but it's breaking on OpenJDK8 on RBE with

Unrecognized option: --add-opens
--
Error: Could not create the Java Virtual Machine.

cgruber avatar Jul 10 '21 02:07 cgruber

Is the RBE-on-Java8 actually running bazel on java8?

cgruber avatar Jul 10 '21 02:07 cgruber

Is the RBE-on-Java8 actually running bazel on java8?

Seems like yes.

CMD="/usr/lib/jvm/java-8-openjdk-amd64/bin/java -Xmx256M -Xms32M -noverify       --add-opens java.base/java.util=ALL-UNNAMED

Could be because of https://github.com/bazelbuild/rules_kotlin/blob/cab143b8fa91d53dbd4b055f977156d315d9db1d/src/main/kotlin/bootstrap.bzl#L103

I think it should be using "@bazel_tools//tools/jdk:current_java_runtime" instead of "@bazel_tools//tools/jdk:current_host_java_runtime".

arunkumar9t2 avatar Jul 10 '21 09:07 arunkumar9t2