-
Notifications
You must be signed in to change notification settings - Fork 112
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
"error: [ExtendsAutoValue] Do not extend an @AutoValue/@AutoOneOf class in non-generated code" flagged by error prone #483
Comments
Reproducer. Apply this diff: diff --git a/WORKSPACE b/WORKSPACE
index c6cad80..f1c1f87 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -7,6 +7,23 @@ load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_depende
rules_closure_dependencies()
rules_closure_toolchains()
+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",
+ ],
+)
+
+http_archive(
+ name = "remote_java_tools_darwin",
+ sha256 = "252520f0cd5dd7e9b18062dc731f8ae248993650f12a9b613fcd9ebda591d242",
+ urls = [
+ "https://github.com/davido/java_tools/releases/download/javac11-v11.0/java_tools_javac11_darwin-v11.0.zip",
+ ],
+)
+
+
http_archive(
name = "bazel_skylib",
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d", And run:
|
Went over this. I don't see rules_closure doing anything special around auto value. Looking at error-prone: the class is suppose to be skipped by javax.annotation.Generated, javax.annotation.processing.Generated annotation. And AutoValue would add that annotation if it exists. So things you can try:
But anyway I don't think there is much to do on the rules_closure if upgrading AutoValue doesn't help. |
@gkdn Thanks for looking into it. I think the issue is similar to If you check the generated files in vim bazel-out/host/bin/java/io/bazel/rules/closure/webfiles/_javac/webfiles/libwebfiles_sourcegenfiles/io/bazel/rules/closure/webfiles/AutoValue_Webfile.java package io.bazel.rules.closure.webfiles;
import io.bazel.rules.closure.Webpath;
import java.nio.file.Path;
// Generated by com.google.auto.value.processor.AutoValueProcessor
final class AutoValue_Webfile extends Webfile { We wouldn't care much that the @generated annotation is missing on generated files, but the new Error Prone version 2.3.4, that I'm trying to upgrade in Bazel (in this PR: [3]) is flagging the code as invalid. I will upload PR for review in a moment. [1] bazelbuild/rules_kotlin#320 |
With the referenced PR, the @generated annotation is now there and this makes new version of Error Prone totally happy, no failure any more: vim bazel-out/host/bin/java/io/bazel/rules/closure/webfiles/_javac/webfiles/libwebfiles_sourcegenfiles/io/bazel/rules/closure/webfiles/AutoValue_Webfile.java package io.bazel.rules.closure.webfiles;
import io.bazel.rules.closure.Webpath;
import java.nio.file.Path;
import javax.annotation.Generated;
@Generated("com.google.auto.value.processor.AutoValueProcessor")
final class AutoValue_Webfile extends Webfile {
private final Webpath webpath;
private final Path zip;
private final String label;
private final BuildInfo.WebfileInfo info; |
The reason why @generated annotation is missing is the same as pointed out by @cushon in google/error-prone#1348 (comment).
Now, as expected, in ./k8-fastbuild/bin/java/io/bazel/rules/closure/webfiles/_javac/webfiles/libwebfiles_sourcegenfiles/io/bazel/rules/closure/webfiles/AutoValue Webfile.java, the annotation is there: package io.bazel.rules.closure.webfiles;
import io.bazel.rules.closure.Webpath;
import java.nio.file.Path;
import javax.annotation.Generated;
@Generated("com.google.auto.value.processor.AutoValueProcessor")
final class AutoValue_Webfile extends Webfile {
[...] But in: ./host/bin/java/io/bazel/rules/closure/webfiles/_javac/webfiles/libwebfiles_sourcegenfiles/io/bazel/rules/closure/webfiles/AutoValue_Webfile.java, it is missing: package io.bazel.rules.closure.webfiles;
import io.bazel.rules.closure.Webpath;
import java.nio.file.Path;
// Generated by com.google.auto.value.processor.AutoValueProcessor
final class AutoValue_Webfile extends Webfile {
[...] The missing annotation generation is using -source 8 -target 8 with a JDK 11 -bootclasspath (because it's targeting the remote JDK 11). So |
Fixes bazelbuild#11446. Java tools are decoupled from Bazel distribution and downloaded from java_tools repository. If some of the tools is updated, the archive name is changed in Bazel and new Bazel release is conducted. If, however, new tool has some breaking changes, then the upgrade needs to be rolled back. To make user experience with upgrading tools less disruptive but still not unnecessary procrastinate releases of important Java tools like javac and Error Prone --incompatible_use_java_tools_beta_release is added and CI-job should be set up to check all downstream projects against upcoming java_tools release. Test Plan: 1. Upgrade Error Prone version to 2.3.4 Bazel that is known to have breaking changes and will break all Bazel users who rely on cross compilation use case. There are ongoing efforts to demote the offensive EP checks to warning severity instead of error, though: [1]. 2. Bump java_tools in beta_release archive to new java_tools distribution that includes Error Prone 2.3.4 3. Build rules_closure with --incompatible_use_java_tools_beta_release would fail with the known issue, because of unsatisfied dependency on javax.annotation: ERROR: /home/davido/projects/rules_closoure/java/io/bazel/rules/closure/BUILD:41:13: Building java/io/bazel/rules/closure/libtarjan.jar (1 source file) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor) failed (Exit 1) bazel-out/host/bin/java/io/bazel/rules/closure/_javac/tarjan/libtarjan_sourcegenfiles/io/bazel/rules/closure/AutoValue_Tarjan_Result.java:6: error: [ExtendsAutoValue] Do not extend an @AutoValue/@AutoOneOf class in non-generated code. final class AutoValue_Tarjan_Result<V> extends Tarjan.Result<V> { ^ (see https://errorprone.info/bugpattern/ExtendsAutoValue) See also upstream issue with in depth explanation what is going on there: [2] 4. Build rules_closure without the incompatible option: all is fine. That would mean, that all broken downstream projects would have enough time to adapt their build tool chains for upgraded dependencies in java_tools distribution. [1] google/error-prone#1619 [2] bazelbuild/rules_closure#483 Change-Id: I352297a8d0d86cecf30821c132c7871383e49b50
Fixes bazelbuild#11446. Java tools are decoupled from Bazel distribution and downloaded from java_tools repository. If some of the tools is updated, the archive name is changed in Bazel and new Bazel release is conducted. If, however, new tool has some breaking changes, then the upgrade needs to be rolled back. To make user experience with upgrading tools less disruptive but still not unnecessary procrastinate releases of important Java tools like javac and Error Prone --incompatible_use_java_tools_beta_release is added and CI-job should be set up to check all downstream projects against upcoming java_tools release. Test Plan: 1. Upgrade Error Prone version to 2.3.4 Bazel that is known to have breaking changes and will break all Bazel users who rely on cross compilation use case. There are ongoing efforts to demote the offensive EP checks to warning severity instead of error, though: [1]. 2. Bump java_tools in beta_release archive to new java_tools distribution that includes Error Prone 2.3.4 3. Build rules_closure with --incompatible_use_java_tools_beta_release would fail with the known issue, because of unsatisfied dependency on javax.annotation: ERROR: /home/davido/projects/rules_closoure/java/io/bazel/rules/closure/BUILD:41:13: Building java/io/bazel/rules/closure/libtarjan.jar (1 source file) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor) failed (Exit 1) bazel-out/host/bin/java/io/bazel/rules/closure/_javac/tarjan/libtarjan_sourcegenfiles/io/bazel/rules/closure/AutoValue_Tarjan_Result.java:6: error: [ExtendsAutoValue] Do not extend an @AutoValue/@AutoOneOf class in non-generated code. final class AutoValue_Tarjan_Result<V> extends Tarjan.Result<V> { ^ (see https://errorprone.info/bugpattern/ExtendsAutoValue) See also upstream issue with in depth explanation what is going on there: [2] 4. Build rules_closure without the incompatible option: all is fine. That would mean, that all broken downstream projects would have enough time to adapt their build tool chains for upgraded dependencies in java_tools distribution. [1] google/error-prone#1619 [2] bazelbuild/rules_closure#483 Change-Id: I352297a8d0d86cecf30821c132c7871383e49b50
Fixes bazelbuild#11446. Java tools are decoupled from Bazel distribution and downloaded from java_tools repository. If some of the tools is updated, the archive name is changed in Bazel and new Bazel release is conducted. If, however, new tool has some breaking changes, then the upgrade needs to be rolled back. To make user experience with upgrading tools less disruptive but still not unnecessary procrastinate releases of important Java tools like javac and Error Prone --incompatible_use_java_tools_beta_release is added and CI-job should be set up to check all downstream projects against upcoming java_tools release. Test Plan: 1. Upgrade Error Prone version to 2.3.4 Bazel that is known to have breaking changes and will break all Bazel users who rely on cross compilation use case. There are ongoing efforts to demote the offensive EP checks to warning severity instead of error, though: [1]. 2. Bump java_tools in beta_release archive to new java_tools distribution that includes Error Prone 2.3.4 3. Build rules_closure with --incompatible_use_java_tools_beta_release would fail with the known issue, because of unsatisfied dependency on javax.annotation: ERROR: /home/davido/projects/rules_closoure/java/io/bazel/rules/closure/BUILD:41:13: Building java/io/bazel/rules/closure/libtarjan.jar (1 source file) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor) failed (Exit 1) bazel-out/host/bin/java/io/bazel/rules/closure/_javac/tarjan/libtarjan_sourcegenfiles/io/bazel/rules/closure/AutoValue_Tarjan_Result.java:6: error: [ExtendsAutoValue] Do not extend an @AutoValue/@AutoOneOf class in non-generated code. final class AutoValue_Tarjan_Result<V> extends Tarjan.Result<V> { ^ (see https://errorprone.info/bugpattern/ExtendsAutoValue) See also upstream issue with in depth explanation what is going on there: [2] 4. Build rules_closure without the incompatible option: all is fine. That would mean, that all broken downstream projects would have enough time to adapt their build tool chains for upgraded dependencies in java_tools distribution. [1] google/error-prone#1619 [2] bazelbuild/rules_closure#483 Change-Id: I352297a8d0d86cecf30821c132c7871383e49b50
As of: [1] Gerrit removed [1] https://gerrit-review.googlesource.com/c/gerrit/+/272773 |
I bumped error prone to 2.3.4 in Bazel, and conducted custom java tools release to catch more warnings in Gerrit Code Review project.
With bumped error prone version I see this breakage in Gerrit build, in
rules_closure
:Workaround for now would be to disable that check or downgrade the severity to warning.
The text was updated successfully, but these errors were encountered: