Require the javac flag -XDaddTypeAnnotationsToSymbol=true for Error Prone invocations (original) (raw)

This bug tracks making the javac flag -XDaddTypeAnnotationsToSymbol=true required for javac invocations that enable Error Prone, on JDK 21.

This would be similar to how the following javac flags are already required here

-XDcompilePolicy=simple
--should-stop=ifError=FLOW

On JDK 21 versions 21.0.8 and newer, -XDaddTypeAnnotationsToSymbol=true enables a fix for the javac bug JDK-8225377: type annotations are not visible to javac plugins across compilation boundaries, which Error Prone currently maintains workarounds for (including here). After this change is made, those workarounds can be removed.

-XDaddTypeAnnotationsToSymbol=true is not required on JDK 22 and newer, the fix for JDK-8225377 is enabled by default in newer versions. (And Error Prone no longer supports JDK versions before 21.)

There are some caveats: