Disallow undeclared access to the $(JAVA) and $(JAVABASE) template variables.
If a rule needs these template variables, it will need to declare a dependency on them in the future by adding @bazel_tools//tools/jdk:current_java_runtime to its toolchains= attribute.
RELNOTES[INC]: In order to access the template variables $(JAVA) and $(JAVABASE), @bazel_tools//tools/jdk:current_java_runtime needs to be added to the toolchains= attribute from now on.
RELNOTES: None.
PiperOrigin-RevId: 178070807
diff --git a/src/test/shell/integration/java_integration_test.sh b/src/test/shell/integration/java_integration_test.sh
index f2f6933..e780b8b 100755
--- a/src/test/shell/integration/java_integration_test.sh
+++ b/src/test/shell/integration/java_integration_test.sh
@@ -635,22 +635,23 @@
function test_jvm_flags_are_passed_verbatim() {
local -r pkg="${FUNCNAME[0]}"
mkdir -p $pkg/java/com/google/jvmflags || fail "mkdir"
- cat >$pkg/java/com/google/jvmflags/BUILD <<'EOF'
+ cat >$pkg/java/com/google/jvmflags/BUILD <<EOF
java_binary(
name = 'foo',
srcs = ['Foo.java'],
main_class = 'com.google.jvmflags.Foo',
+ toolchains = ['${TOOLS_REPOSITORY}//tools/jdk:current_java_runtime'],
jvm_flags = [
# test quoting
- '--a=\'single_single\'',
+ '--a=\\'single_single\\'',
'--b="single_double"',
"--c='double_single'",
- "--d=\"double_double\"",
+ "--d=\\"double_double\\"",
'--e=no_quotes',
# no escaping expected
- '--f=stuff$$to"escape\\',
+ '--f=stuff\$\$to"escape\\\\',
# test make variable expansion
- '--g=$(JAVABASE)',
+ '--g=\$(JAVABASE)',
],
)
EOF