Fix JavaBuilder bug when the source files are empty.
--
MOS_MIGRATED_REVID=104112686
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java
index e086efd..9c29c0c 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java
@@ -29,7 +29,6 @@
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.api.MultiTaskListener;
-import com.sun.tools.javac.comp.CompileStates.CompileState;
import com.sun.tools.javac.main.Main;
import com.sun.tools.javac.main.Main.Result;
import com.sun.tools.javac.util.Context;
@@ -151,8 +150,12 @@
} finally {
if (result.isOK()) {
verifyNotNull(compiler);
- if (compiler.shouldStopPolicyIfNoError.isAfter(CompileState.FLOW)
- && compiler.flowEvents() == 0) {
+ // There could be situations where we incorrectly skip Error Prone and the compilation
+ // ends up succeeding, e.g., if there are errors that are fixed by subsequent round of
+ // annotation processing. This check ensures that if there were any flow events at all,
+ // then plugins were run. There may legitimately not be any flow events, e.g. -proc:only
+ // or empty source files.
+ if (compiler.skippedFlowEvents() > 0 && compiler.flowEvents() == 0) {
errOutput.println("Expected at least one FLOW event");
result = Result.ABNORMAL;
}