Skip to content

Commit 6f11849

Browse files
committed
Java: Add test.
1 parent 0c37ea8 commit 6f11849

File tree

1 file changed

+22
-0
lines changed
  • java/ql/test/query-tests/UselessComparisonTest

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
import java.util.function.*;
3+
4+
public class B {
5+
int modcount = 0;
6+
7+
int[] arr;
8+
9+
public void modify(IntUnaryOperator func) {
10+
int mc = modcount;
11+
for (int i = 0; i < arr.length; i++) {
12+
arr[i] = func.applyAsInt(arr[i]);
13+
}
14+
// Always false unless there is a call path from func.applyAsInt(..) to
15+
// this method, but should not be reported, as checks guarding
16+
// ConcurrentModificationExceptions are expected to always be false in the
17+
// absence of API misuse.
18+
if (mc != modcount)
19+
throw new ConcurrentModificationException();
20+
modcount++;
21+
}
22+
}

0 commit comments

Comments
 (0)