Repository: bazelbuild/bazel
Issue: javac turbine needs to be updated
Labels: team-Rules-Java

Since d42a026e63872efb9f9f3879248ddf4431c65d20, I've been seeing failures like this:
```
java -Xverify:none -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9+181-r4173-1.jar -jar external/bazel_tools/tools/jdk/turbine_deploy.jar --output ... (remaining 221 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox.
Exception in thread "main" java.lang.IllegalArgumentException: unknown option: --reduce_classpath
	at com.google.turbine.options.TurbineOptionsParser.parse(TurbineOptionsParser.java:123)
	at com.google.turbine.options.TurbineOptionsParser.parse(TurbineOptionsParser.java:53)
	at com.google.turbine.options.TurbineOptionsParser.parse(TurbineOptionsParser.java:41)
	at com.google.devtools.build.java.turbine.javac.JavacTurbine.main(JavacTurbine.java:81)
```

Issue comments:
Hmm, I thought I had updated it: 9259683c6b460629d1ca83759ce26fa76839558d

Are you building with any `--incompatible_` flags?
I think the problem is that there's also `third_party/java/java_tools/turbine_deploy.jar`.
I hacked up an integration test to demonstrate the problem:
```
$ git diff
diff --git a/src/test/shell/integration/java_integration_test.sh b/src/test/shell/integration/java_integration_test.sh
index 9435e13101..fc0790afea 100755
--- a/src/test/shell/integration/java_integration_test.sh
+++ b/src/test/shell/integration/java_integration_test.sh
@@ -634,6 +634,7 @@ java_library(name = 'processor_dep',
 
 java_plugin(name = 'processor',
   processor_class = 'test.processor.Processor',
+  generates_api = True,
   deps = [ ':annotation', ':processor_dep' ],
   srcs = [ 'Processor.java' ])
 EOF
@@ -695,6 +696,10 @@ java_library(name = 'client',
      srcs = [ 'ProcessorClient.java' ],
      deps = [ '//$pkg/java/test/processor:annotation' ],
   plugins = [ '//$pkg/java/test/processor:processor' ])
+
+java_binary(name = 'bin',
+  srcs = ['MyBinary.java'],
+  deps = [':client'])
 EOF
 
   cat >$pkg/java/test/client/ProcessorClient.java <<EOF
@@ -704,11 +709,19 @@ import test.processor.TestAnnotation;
 class ProcessorClient { }
 EOF
 
-  bazel build ${bazel_opts[@]+"${bazel_opts[@]}"} //$pkg/java/test/client:client --use_ijars || fail "build failed"
+  cat > $pkg/java/test/client/MyBinary.java <<EOF
+class MyBinary {
+  public static void main(String[] args) {
+    new ProcessorClient();
+  }
+}
+EOF
+
+  bazel build ${bazel_opts[@]+"${bazel_opts[@]}"} //$pkg/java/test/client:bin || fail "build failed"
   unzip -l ${PRODUCT_NAME}-bin/$pkg/java/test/client/libclient.jar > $TEST_log
   expect_log " test/Generated.class" "missing class file from annotation processing"
 
-  bazel build ${bazel_opts[@]+"${bazel_opts[@]}"} //$pkg/java/test/client:libclient-src.jar --use_ijars \
+  bazel build ${bazel_opts[@]+"${bazel_opts[@]}"} //$pkg/java/test/client:libclient-src.jar \
     || fail "build failed"
   unzip -l ${PRODUCT_NAME}-bin/$pkg/java/test/client/libclient-src.jar > $TEST_log
   expect_log " test/Generated.java" "missing source file from annotation processing"
$ bazel test //src/test/shell/integration:java_integration_test --test_filter test_java_plugin
```
Thanks, I'd forgotten about #7196.

It's concerning that there apparently aren't any integration tests using `generates_api`.

@lberki are there plans for more automation around `third_party/java/java_tools/update_java_tools.sh`?
Closing since 92adff893fbd185269bf734abf4d3b12d3117ebc fixed the immediate problem. It does seem like there should be an integration test for javac turbine.
I'm getting this error on 0.23.0 with `--all_incompatible_changes`.

Pull request review comments:
nit: Isn't this duplicated from the 0.22 (see line 38 in the same file?)
The file didn't have a trailing newline, the only thing that changed on this line was trailing whitespace.
Oh, also, I think the duplication with 38 is deliberate? The script is printing the list of files that change in each update, and this file changed in this update and the one below.

Patch that resolved the issue:
diff --git a/third_party/java/java_tools/README.md b/third_party/java/java_tools/README.md
index 408669c11285fc..fd029df6fe0751 100644
--- a/third_party/java/java_tools/README.md
+++ b/third_party/java/java_tools/README.md
@@ -21,4 +21,20 @@ third_party/java/java_tools/SingleJar_deploy.jar
 The following tools were built with bazel 0.21.0 at commit 019f13b64630ea7e7837a2ed8b664c4262322b1c by running:
 $ third_party/java/java_tools/update_java_tools.sh
 
-third_party/java/java_tools/jarjar_command_deploy.jar
\ No newline at end of file
+third_party/java/java_tools/jarjar_command_deploy.jar
+
+The following tools were built with bazel 0.22.0 at commit ee1107a6ada146666f50aa7e834e9f954153de32
+by running:
+$ third_party/java/java_tools/update_java_tools.sh 
+
+third_party/java/java_tools/turbine_deploy.jar
+third_party/java/java_tools/ExperimentalRunner_deploy.jar
+third_party/java/java_tools/bazel-singlejar_deploy.jar
+third_party/java/java_tools/GenClass_deploy.jar
+third_party/java/java_tools/VanillaJavaBuilder_deploy.jar
+third_party/java/java_tools/JacocoCoverage_jarjar_deploy.jar
+third_party/java/java_tools/turbine_direct_binary_deploy.jar
+third_party/java/java_tools/JavaBuilder_deploy.jar
+third_party/java/java_tools/jarjar_command_deploy.jar
+third_party/java/java_tools/Runner_deploy.jar
+
diff --git a/third_party/java/java_tools/update_java_tools.sh b/third_party/java/java_tools/update_java_tools.sh
index c77013c3c2855f..50be12fa3689ec 100755
--- a/third_party/java/java_tools/update_java_tools.sh
+++ b/third_party/java/java_tools/update_java_tools.sh
@@ -99,12 +99,13 @@ done
 if [[ ${#updated_tools[@]} -gt 0 ]]; then
   bazel_version=$(bazel version | grep "Build label" | cut -d " " -f 3)
   git_head=$(git rev-parse HEAD)
-  echo ""
-  echo "Please copy/paste the following into third_party/java/java_tools/README.md:"
-  echo ""
-  echo "The following tools were built with bazel $bazel_version at commit $git_head \
+  cat >>third_party/java/java_tools/README.md <<EOL
+
+The following tools were built with bazel $bazel_version at commit $git_head
 by running:
 $ third_party/java/java_tools/update_java_tools.sh $@
-"
-  ( IFS=$'\n'; echo "${updated_tools[*]}" )
+
+$( IFS=$'\n'; echo "${updated_tools[*]}" )
+
+EOL
 fi


Test patch: