-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive for ImmutableAnnotationChecker check on Java 11 #1348
Comments
The severity of this check was demoted to WARN in Id7911fb6dd8. But then was promoted again to ERROR in I72d6044a4d5. However, the root cause of the compilation breakage is the Error Prone false positive error reporting for ImmutableAnnotationChecker check on Java 11 and later: [1], [2]. Disable the check for now, and consider to re-enable it again, when the breakage is fixed upstream. This is needed to support building Gerrit on Java 11 and newer Java versions. [1] bazelbuild/bazel#9378 [2] google/error-prone#1348 Change-Id: Ib1778629fef5e2f61891ff0a176e4b5c74f2aa8a
Recent versions of Error Prone disable that check on AutoAnnotation-generated code: 11e28aa, and recent versions of AutoAnnotation should be using the correct Please re-open if this is still happening with recent versions of Error Prone / bazel AutoAnnotation. |
Unfortunately this fix regresses for Java language source level 8, because it requires This regression was also the root cause, why recent attempt to bump EP version in Bazel was reverted: [1],[2],[3] because both rules_closure and rules_kotlin were affected by very similar change: 5ad37b7. This is still happening with EP 2.3.4 and Bazel@HEAD and custom release of WORKSPACE diff --git a/WORKSPACE b/WORKSPACE
index 38cc59b..3341338 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,4 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:maven_rules.bzl", "maven_jar")
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
maven_jar(
name = "args4j",
@@ -25,3 +26,13 @@ maven_jar(
artifact = "com.google.guava:guava:28.1-jre",
sha1 = "b0e91dcb6a44ffb6221b5027e12a5cb34b841145",
)
+
+http_archive(
+ name = "remote_java_tools_linux",
+ sha256 = "74d30ccf161c58bb69db9b2171c954a0563b2d1ff6f5831debbe71ced105c388",
+ urls = [
+ "https://github.com/davido/java_tools/releases/download/javac11-v11.0/java_tools_javac11_linux-v11.0.zip",
+ ],
+)
outcome:
Reason is, that
The fix is to add WORKSPACE +maven_jar(
+ name = "javax-annotation",
+ artifact = "javax.annotation:javax.annotation-api:1.3.2",
+ sha1 = "934c04d3cfef185a8008e7bf34331b79730a9d43",
+) BUILD:
Now, the annotation is generated: import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import javax.annotation.Generated;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.OptionHandler;
@Generated("com.google.auto.value.processor.AutoAnnotationProcessor")
final class AutoAnnotation_OptionUtil_newOption implements Option { and the EP check is skipped:
[1] bazelbuild/bazel#9286 |
@cushon Thanks for re-opening this issue again. After all the research that I did on that topic, including opening multiple issues across different projects: [1], [2], I think that 11e28aa, 5ad37b7 and friends were very intrusive and backwards incomptatible changes. It would break each and every client that rely on code generation and update EP to the new version, as have been seen by I am not sure what is the right way to communicate the backwards incompatible changes for EP project, but may be we should close this issue and open a follow-up issue so that the potential breakages of clients as the consequence of 11e28aa, 5ad37b7 and friends should be properly announced? [1] #1599 |
The failing compilation is using This issue wouldn't affect consistent cross-compilation configurations, i.e |
The situation is even worse. For builder projects (both In short it doesn't work and false positive would be reported even with:
|
That's still an example of
|
It would be nice if Bazel had a better way to handle bootclasspaths for cross compilation with Would that mitigate the issue you're seeing? The repro uses |
Yes. All checks, that are relying on availability of
Yes. The reproducer was created based on the real breakage of Gerrit Code Review build, after switching to local JDK 11: [1] and thus having exactly the described cross compilation Bazel problem. As you may know, Gerrit project promoted the severity levels for many EP checks in its build tool chain: [2] to error, and promoting the severity for [1] https://gerrit-review.googlesource.com/c/gerrit/+/237183 |
…ings to avoid break builds that don't have an `@Generated` annotation available, see discussion in: #1348 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=312115507
…ings to avoid break builds that don't have an `@Generated` annotation available, see discussion in: #1348 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=312115507
The following issue has been fixed and check can be enabled: google/error-prone#1348 Change-Id: I4caa6b4f54efa3d68d8e2c35a9e7f8b1871f3ca8
When switching to using Java 11,
ImmutableAnnotationChecker
check is starting to fail forAutoAnnotaion
class. On Java 8 the check is passing, even whenString[]
attributes are used. Changing the attributes from String[] to ImmutableList[] as suggested in [2] doesn't fix it.Reproducer is here: [1]:
The generated code is here: [3]. As can be seen, the generated getter is:
When building on Java 8, all is fine, and that is why the problem wasn't detected for so long time:
I have also reported the problem on Bazel issue tracker, as it wasn't clear to me if this is a Bazel or EP issue: [4].
[1] https://github.com/davido/error_prone_auto_annotation_java11_breakage
[2] https://errorprone.info/bugpattern/ImmutableAnnotationChecker
[3] http://paste.openstack.org/show/775768
[4] bazelbuild/bazel#9378
The text was updated successfully, but these errors were encountered: