Yes, I found this configuration parameter, but now I have a new problem.
Now I set default_java_toolchain added the parameters I need. In BUILD.
load(
"@bazel_tools//tools/jdk:default_java_toolchain.bzl",
"default_java_toolchain", "DEFAULT_TOOLCHAIN_CONFIGURATION", "JDK9_JVM_OPTS", "DEFAULT_JAVACOPTS"
)
default_java_toolchain(
name = "bootstrap_toolchain",
#configuration = DEFAULT_TOOLCHAIN_CONFIGURATION, # One of predefined configurations
# Other parameters are from java_toolchain rule:
java_runtime = "@bazel_tools//tools/jdk:remote_jdk11", # JDK to use for compilation and toolchain's tools execution
jvm_opts = JDK9_JVM_OPTS + [
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-modules=java.base,java.compiler",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
], # Additional JDK options
javacopts = DEFAULT_JAVACOPTS, # Additional javac options
)
And it is set in the .bazelrc file
build --java_language_version=11
build --java_toolchain=@bazel_tools//tools/jdk:toolchain
build --javabase=@bazel_tools//tools/jdk:remote_jdk11
build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain
build --host_javabase=@bazel_tools//tools/jdk:remote_jdk11
build:remote --host_javabase=@bazel_tools//tools/jdk:remote_jdk11
build:remote --javabase=@bazel_tools//tools/jdk:remote_jdk11
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain
Now the compilation is successful, but it seems that all the java files still rely on jdk8 to compile after the compilation results are decompiled by javap - v
I don't understand why jdk11 is not used. Am I not configured correctly?