//src:derived_java_srcs: use jar from JAVABASE instead of PATH

The genrule //src:derived_java_srcs so far assumed to find the
needed tool jar(1) on PATH. This, however, is not true in all
setups. Instead, use jar from JAVABASE, which should be the correct
toolchain to be used on the execution platform. Fixes #3284.

Change-Id: I1f972f819786b511237c448a6c57484a76f4118b
PiperOrigin-RevId: 160634222
diff --git a/src/BUILD b/src/BUILD
index 6fb595a..1ba651c 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -399,7 +399,7 @@
         "@googleapis//:dist_jars",
     ],
     outs = ["derived_java_srcs.zip"],
-    cmd = "$(location :combine_derived_java_srcs.sh) $@ $(SRCS)",
+    cmd = "$(location :combine_derived_java_srcs.sh) $(JAVABASE) $@ $(SRCS)",
     tools = ["combine_derived_java_srcs.sh"],
     visibility = ["//:__pkg__"],
 )
diff --git a/src/combine_derived_java_srcs.sh b/src/combine_derived_java_srcs.sh
index 7a306a6..e28c8c7 100755
--- a/src/combine_derived_java_srcs.sh
+++ b/src/combine_derived_java_srcs.sh
@@ -18,6 +18,8 @@
 
 # Combine src jars to a single archive containing all the source files.
 
+JAVABASE="${PWD}/$1"
+shift
 OUTPUT="${PWD}/$1"
 shift
 
@@ -30,7 +32,7 @@
 for i in $*
 do
     JARFILE="${PWD}/$i"
-    (cd "${JAVA_SRC_DIR}" && jar xf "${JARFILE}")
+    (cd "${JAVA_SRC_DIR}" && "${JAVABASE}/bin/jar" xf "${JARFILE}")
 done
 
 find "${PACKAGE_DIR}" -exec touch -t 198001010000.00 '{}' '+'