mirror of
https://github.com/github/codeql.git
synced 2026-04-21 06:55:31 +02:00
Java: Add test.
This commit is contained in:
22
java/ql/test/query-tests/UselessComparisonTest/B.java
Normal file
22
java/ql/test/query-tests/UselessComparisonTest/B.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
|
||||
public class B {
|
||||
int modcount = 0;
|
||||
|
||||
int[] arr;
|
||||
|
||||
public void modify(IntUnaryOperator func) {
|
||||
int mc = modcount;
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = func.applyAsInt(arr[i]);
|
||||
}
|
||||
// Always false unless there is a call path from func.applyAsInt(..) to
|
||||
// this method, but should not be reported, as checks guarding
|
||||
// ConcurrentModificationExceptions are expected to always be false in the
|
||||
// absence of API misuse.
|
||||
if (mc != modcount)
|
||||
throw new ConcurrentModificationException();
|
||||
modcount++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user