-
Notifications
You must be signed in to change notification settings - Fork 578
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
Java 17 - False positive SA_LOCAL_SELF_COMPARISON when using instanceof pattern matching #1992
Comments
I'm seeing the same issue with jdk 17: {
public List<VersionRange> _rangesFor(VersionConstraint constraint) throws ArgumentException
{
if (constraint.isEmpty())
return new ArrayList<VersionRange>();
if (constraint instanceof VersionUnion union) // this line generates the false positive.
return union.ranges;
throw new ArgumentException("Unknown VersionConstraint type $constraint.");
} VersionUnion.java:281 Self comparison of constraint with itself |
I'm also seeing this, but only when using ECJ (Eclipse compiler) via maven-compiler-plugin. |
When compiling the following example
with ejc (and then decompiling with javap) I get
which indeed has a reference check ("if_acmpne") that compares two reference that are always equal. The duplicate "checkcast"-pattern seeems like a bug in ejc to me.
which is what I'd expect and which shouldn't trigger the spotbugs warning. |
Another bug in
(at |
This cleanup includes: * Fix deprecations * Fix JavaDocs * Remove redundant toString calls * Remove redundant semicolons * Simplify boolean expressions * Use diamond operator * Use enhanced for loops * Use instanceof pattern matching * Use isEmpty instead of 0 comparisons * Use lambdas * Use static inner classes * Use StandardCharsets Also adds the SA_LOCAL_SELF_COMPARISON suppression similar as used in other repositories for spotbugs/spotbugs#1992. Signed-off-by: Wouter Born <github@maindrain.net>
This cleanup includes: * Fix deprecations * Fix JavaDocs * Remove redundant toString calls * Remove redundant semicolons * Simplify boolean expressions * Use diamond operator * Use enhanced for loops * Use instanceof pattern matching * Use isEmpty instead of 0 comparisons * Use lambdas * Use static inner classes * Use StandardCharsets Also adds the SA_LOCAL_SELF_COMPARISON suppression similar as used in other repositories for spotbugs/spotbugs#1992. Signed-off-by: Wouter Born <github@maindrain.net>
So this seems to be an issue with ECJ as described here: eclipse-jdt/eclipse.jdt.core#1406 |
Hi,
there seems to still be an issue with the problem stated in the title.
It was taken care of way back but is now (again?) relevant. Back then there were PRs to test/fix it: #1136 and #1435
We are using:
There are serveral other similar issues and comments here mentioning this sitiuation:
Is it maybe possible, that this check/exclusion only works for Java 14 but not 15, 16, 17, ...?
For now we will probaby disable these checks.
Many thanks in advance,
Cheers, Paul
The text was updated successfully, but these errors were encountered: