| 3 | import edu.umd.cs.findbugs.annotations.NoWarning; |
| 4 | |
| 5 | public class SelfFieldOperation { |
| 6 | |
| 7 | public SelfFieldOperation(int x, long y, int z, Integer a) { |
| 8 | this.x = x; |
| 9 | this.y = y; |
| 10 | this.z = z; |
| 11 | this.a = a; |
| 12 | } |
| 13 | |
| 14 | int x; |
| 15 | long y; |
| 16 | |
| 17 | volatile int z; |
| 18 | |
| 19 | @NoWarning(value="SA_FIELD_SELF_COMPARISON", confidence = Confidence.MEDIUM) |
| 20 | @ExpectWarning(value="SA_FIELD_SELF_COMPARISON", confidence = Confidence.LOW) |
| 21 | boolean volatileFalsePositive() { |
| 22 | return z == z; |
| 23 | } |
| 24 | |
| 25 | @ExpectWarning("SA_FIELD_SELF_COMPARISON,SA_FIELD_SELF_COMPUTATION") |
| 26 | int f() { |
| 27 | if (x < x) |
| 28 | x = (int) ( y ^ y); |
| 29 | if (x != x) |
| 30 | y = x | x; |
| 31 | if (x >= x) |
| 32 | x = (int)(y & y); |
| 33 | if (y > y) |
| 34 | y = x - x; |
| 35 | return x; |
| 36 | } |
| 37 | |
| 38 | double f1; |
| 39 | @NoWarning("SA_FIELD_SELF_COMPARISON") |
| 40 | int doubleOK() { |
| 41 | if (f1 < f1) |
| 42 | return 1; |
| 43 | if (f1 <= f1) |
| 44 | return 2; |
| 45 | if (f1 == f1) |
| 46 | return 3; |
| 47 | if (f1 != f1) |
| 48 | return 4; |
| 49 | if (f1 > f1) |
| 50 | return 5; |
| 51 | if (f1 >= f1) |
| 52 | return 6; |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | Integer a; |
| 57 | |
| 58 | @ExpectWarning("SA_FIELD_SELF_COMPARISON") |
| 59 | boolean e() { |
| 60 | return a.equals(a); |
| 61 | } |
| 62 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…