-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 Prone: ReturnValueIgnored bug pattern is flagged with Java 11 toolchain but not with Java 17 toolchain #14587
Comments
That Passing
|
I'm not entirely sure why you're seeing this for 11 and not 17. Are you using versions of those toolchains that use the same version of Error Prone, and are configured the same way? |
Yes. Everything is the same. I am seeing the same behavior with Bazel version: 5.0.0rc4, see I can also confirm that with this diff: diff --git a/tools/BUILD b/tools/BUILD
index 18b667f490..bb5586b6dc 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -388,6 +388,7 @@ java_package_configuration(
"-Xep:RethrowReflectiveOperationExceptionAsLinkageError:ERROR",
"-Xep:ReturnFromVoid:ERROR",
"-Xep:ReturnValueIgnored:ERROR",
+ "-XepOpt:ReturnValueIgnored:ObjectMethods=true",
"-Xep:RxReturnValueIgnored:ERROR",
"-Xep:SameNameButDifferent:ERROR",
"-Xep:SelfAssignment:ERROR", The build is failing as expected also on Java 17:
So that the question remains: why |
The commit I linked to adds Gerrit's The |
I will overwrite default_java_toolchain(
name = "error_prone_warnings_toolchain_java17",
configuration = dict(),
java_runtime = "@bazel_tools//tools/jdk:remotejdk_17",
misc = [
"-XDskipDuplicateBridges=true",
"-XDcompilePolicy=simple",
"-g",
"-parameters",
# https://github.com/bazelbuild/java_tools/issues/51#issuecomment-927940699
# "-XepOpt:ReturnValueIgnored:ObjectMethods=false",
],
package_configuration = [
":error_prone",
],
source_version = "17",
target_version = "17",
visibility = ["//visibility:public"],
) Thanks for the quick help! Should we file a follow-up issue to remove this exclusion in Bazel: bazel@HEAD
We should fix Bazel code or add |
Per default the attributes of default_java_toolchain macro is set to correct values, so that we don't need to specify them. Moreover, a new Bazel release could set new values, so that own values would override the default values and thus revert them. This is the case with default_java_toolchain.misc attribute. During Error Prone upgrade, a new option was added -XepOpt:ReturnValueIgnored:ObjectMethods=true, but overridden in our own impementation, see: [1],[2]. This is a preparation change to update Bazel version to 5.x release. [1] bazelbuild/bazel#14587 [2] bazelbuild/bazel#14589 Change-Id: Ib7986555c3dabacc17db11cc7787b526fb31012b
Per default the attributes of default_java_toolchain macro is set to correct values, so that we don't need to specify them. Moreover, a new Bazel release could set new values, so that own values would override the default values and thus revert them. This is the case with default_java_toolchain.misc attribute. During Error Prone upgrade, a new option was added -XepOpt:ReturnValueIgnored:ObjectMethods=true, but overridden in our own impementation, see: [1],[2]. This is a preparation change to update Bazel version to 5.x release. [1] bazelbuild/bazel#14587 [2] bazelbuild/bazel#14589 Release-Notes: skip Change-Id: Ib7986555c3dabacc17db11cc7787b526fb31012b
On Bazel@HEAD (38117d4) I try to build this code with different toolchains:
javatests/com/google/gerrit/common/data/GroupReferenceTest.java
With Java 11 the issue is reported as expected:
On Java 17 (default configuration), the problem is unexpectedly not flagged:
To reproduce, fetch this change: [1] and run the above mentioned commands.
Also note, that
"-Xep:FutureReturnValueIgnored:ERROR"
was enabled in custom toolchain (defined intools/BUILD
) in both cases (and this custom toolchain definition is used: If I promote"-Xep:JavaUtilDate:WARN"
to-Xep:JavaUtilDate:ERROR"
the build would fail as expected).//CC @cushon @comius
[1] https://gerrit-review.googlesource.com/c/gerrit/+/327739
The text was updated successfully, but these errors were encountered: