Automated rollback of https://github.com/bazelbuild/bazel/commit/808ec9ff9b5cec14f23a4ba106bc5249cacc8c54 and https://github.com/bazelbuild/bazel/commit/4c9149d558161e7d3e363fb697f5852bc5742a36 and some manual merging.

Fixes #6035.

This change rolls back the version of the JDK embedded into Bazel to 9.

*** Reason for rollback ***

Bazel 0.17 still needs to support JDK 8 and we need to roll out nits deprecation behind a flag of some sort.

*** Original change description ***

Clean up Java toolchain configuration

now that JDK 8 host_javabases are no longer supported.

PiperOrigin-RevId: 211953405
diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD
index a8a13cb..4e8888c 100644
--- a/tools/jdk/BUILD
+++ b/tools/jdk/BUILD
@@ -4,6 +4,8 @@
     "//tools/jdk:default_java_toolchain.bzl",
     "default_java_toolchain",
     "java_runtime_files",
+    "JDK8_JVM_OPTS",
+    "JDK9_JVM_OPTS",
     "DEFAULT_JAVACOPTS",
 )
 
@@ -191,7 +193,7 @@
     actual = "@embedded_jdk//:jdk",
 )
 
-RELEASES = (8, 9, 10)
+RELEASES = (8, 9)
 
 # Create jars containing compile-time bootclasspaths for each Java version
 # in RELEASES, using javac to read those APIs via the infrastructure added
@@ -221,9 +223,7 @@
 default_java_toolchain(
     name = "toolchain_hostjdk8",
     bootclasspath = [":platformclasspath8"],
-    forcibly_disable_header_compilation = True,
-    javabuilder = [":vanillajavabuilder"],
-    jvm_opts = [],
+    jvm_opts = JDK8_JVM_OPTS,
     source_version = "8",
     target_version = "8",
 )
@@ -231,7 +231,7 @@
 # Default to the Java 8 language level.
 # TODO(cushon): consider if/when we should increment this?
 alias(
-    name = "toolchain",
+    name = "toolchain_hostjdk9",
     actual = "toolchain_java8",
 )
 
@@ -239,12 +239,18 @@
     default_java_toolchain(
         name = "toolchain_java%d" % release,
         bootclasspath = [":platformclasspath%d" % release],
+        jvm_opts = JDK9_JVM_OPTS,
         source_version = "%s" % release,
         target_version = "%s" % release,
     )
     for release in RELEASES
 ]
 
+alias(
+    name = "toolchain",
+    actual = "//external:java_toolchain",
+)
+
 filegroup(
     name = "srcs",
     srcs = [