Convey the value of the --host_javabase startup option to the server.

--
PiperOrigin-RevId: 149282686
MOS_MIGRATED_REVID=149282686
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index eec8f47..5fdf5ad 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -481,6 +481,11 @@
     result.push_back("--use_custom_exit_code_on_abrupt_exit=false");
   }
 
+  if (!globals->options->GetExplicitHostJavabase().empty()) {
+    result.push_back("--host_javabase=" +
+                     globals->options->GetExplicitHostJavabase());
+  }
+
   // This is only for Blaze reporting purposes; the real interpretation of the
   // jvm flags occurs when we set up the java command line.
   if (globals->options->host_jvm_debug) {
diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc
index 9c1a16b..b605de3 100644
--- a/src/main/cpp/startup_options.cc
+++ b/src/main/cpp/startup_options.cc
@@ -348,8 +348,17 @@
 
 string StartupOptions::GetHostJavabase() {
   if (host_javabase.empty()) {
-    host_javabase = GetDefaultHostJavabase();
+    if (default_host_javabase.empty()) {
+      default_host_javabase = GetDefaultHostJavabase();
+    }
+
+    return default_host_javabase;
+  } else {
+    return host_javabase;
   }
+}
+
+string StartupOptions::GetExplicitHostJavabase() const {
   return host_javabase;
 }
 
diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h
index 7bde6e7..a931ab9 100644
--- a/src/main/cpp/startup_options.h
+++ b/src/main/cpp/startup_options.h
@@ -195,6 +195,10 @@
   // the --host_javabase option.
   std::string GetHostJavabase();
 
+  // Returns the explicit value of the --host_javabase startup option or the
+  // empty string if it was not specified on the command line.
+  std::string GetExplicitHostJavabase() const;
+
   // Port for gRPC command server. 0 means let the kernel choose, -1 means no
   // gRPC command server.
   int command_port;
@@ -230,6 +234,7 @@
 
  private:
   std::string host_javabase;
+  std::string default_host_javabase;
 };
 
 }  // namespace blaze