Upgrade to bazel 0.19.0-rc5

Sandbox java as well!

Change-Id: If46914a08ea05b3ae915727b6e89ec45c703645b
diff --git a/tools/bazel.rc b/.bazelrc
similarity index 85%
rename from tools/bazel.rc
rename to .bazelrc
index 1dee9b5..7f7a2ac 100644
--- a/tools/bazel.rc
+++ b/.bazelrc
@@ -65,4 +65,15 @@
 startup --host_jvm_args=-Dbazel.DigestFunction=SHA1
 
 common --watchfs
+
+# Switch to SHA256 for compatibility with distributed caching.
+startup --host_jvm_args=-Dbazel.DigestFunction=SHA256
+
 build --spawn_strategy=linux-sandbox
+build --experimental_sandbox_default_allow_network=false
+
+# Use our hermetic JDK.
+# Note that this doesn't quite work fully, but it should. See
+# https://github.com/bazelbuild/bazel/issues/6341 for ongoing discussion with
+# upstream about this.
+build --javabase=@openjdk_linux_archive//:jdk --host_javabase=@openjdk_linux_archive//:jdk
diff --git a/WORKSPACE b/WORKSPACE
index 90a57b3..7aaff90 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -270,3 +270,21 @@
     sha256 = "d564dda558570344b4caa66c5bae2cdae9ef68e07829d64f5651b25f2c6a0e9e",
     url = "http://frc971.org/Build-Dependencies/cgal-dev-4.5-2.tar.gz",
 )
+
+# Java9 JDK.
+new_http_archive(
+    name = "openjdk_linux_archive",
+    build_file_content = """
+java_runtime(
+    name = 'jdk',
+    srcs = glob(['**']),
+    visibility = ['//visibility:public']
+)
+""",
+    sha256 = "f27cb933de4f9e7fe9a703486cf44c84bc8e9f138be0c270c9e5716a32367e87",
+    strip_prefix = "zulu9.0.7.1-jdk9.0.7-linux_x64-allmodules",
+    urls = [
+        "http://frc971.org/Build-Dependencies/zulu9.0.7.1-jdk9.0.7-linux_x64-allmodules.tar.gz",
+    ],
+)
+
diff --git a/doc/make_bazel_package.sh b/doc/make_bazel_package.sh
index eb2503c..c961814 100755
--- a/doc/make_bazel_package.sh
+++ b/doc/make_bazel_package.sh
@@ -9,7 +9,7 @@
 
 BAZEL_SOURCE="$1"
 
-VERSION="$(date +%Y%m%d%H%M)+$(GIT_DIR="${BAZEL_SOURCE}/.git" git rev-parse --short HEAD)"
+VERSION="0.19.0rc4-$(date +%Y%m%d%H%M)+$(GIT_DIR="${BAZEL_SOURCE}/.git" git rev-parse --short HEAD)"
 OUTPUT="bazel_${VERSION}"
 
 (
diff --git a/tools/bazel b/tools/bazel
index fe2a296..6f5230c 100755
--- a/tools/bazel
+++ b/tools/bazel
@@ -24,8 +24,7 @@
   exec "${BAZEL_OVERRIDE}" "$@"
 fi
 
-readonly VERSION="201807071512+aa7e972"
-#bazel_201807071512+aa7e972.xz
+readonly VERSION="0.19.0rc4-201810201638+ac88041"
 
 readonly DOWNLOAD_DIR="$(dirname "${BASH_SOURCE[0]}")/../bazel-downloads"
 # Directory to unpack bazel into.  This must change whenever bazel changes.
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index d541a8a..d2e2fda 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -103,6 +103,7 @@
     static_runtime_libs = [":empty"],
     strip_files = ":clang_3p6_strip_files",
     supports_param_files = 1,
+    toolchain_identifier = "k8_linux",
 )
 
 filegroup(
@@ -156,6 +157,7 @@
     static_runtime_libs = [":empty"],
     strip_files = ":roborio_strip_files",
     supports_param_files = 1,
+    toolchain_identifier = "roborio_linux",
 )
 
 filegroup(
@@ -214,6 +216,7 @@
     static_runtime_libs = [":empty"],
     strip_files = ":linaro_linux_strip_files",
     supports_param_files = 1,
+    toolchain_identifier = "clang_linux_armhf",
 )
 
 filegroup(
@@ -256,6 +259,7 @@
     static_runtime_libs = [":empty"],
     strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
     supports_param_files = 1,
+    toolchain_identifier = "cortex-m4f",
 )
 
 cc_toolchain(
@@ -270,6 +274,7 @@
     static_runtime_libs = [":empty"],
     strip_files = ":empty",
     supports_param_files = 1,
+    toolchain_identifier = "cortex-m4f-k22",
 )
 
 py_binary(