A DESCRIPTION OF THE PROBLEM :
Because the return type of the method BitSet#size is int, so the method may return a negative value in some case, for example, will return -2147483648.
```
BitSet bitSet = new BitSet(Integer.MAX_VALUE);
for (int i = 0; i < Integer.MAX_VALUE - 1000; i++) {
bitSet.set(i);
}
System.out.println(bitSet.size());
```
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
BitSet bitSet = new BitSet(Integer.MAX_VALUE);
for (int i = 0; i < Integer.MAX_VALUE - 1000; i++) {
bitSet.set(i);
}
System.out.println(bitSet.size());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
137438953408
ACTUAL -
-2147483648
---------- BEGIN SOURCE ----------
public class TestBitSetSize {
public static void main(String[] args) throws Exception {
java.util.BitSet bitSet = new java.util.BitSet(Integer.MAX_VALUE);
for (int i = 0; i < Integer.MAX_VALUE - 1000; i++) {
bitSet.set(i);
}
System.out.println(bitSet.size());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
change the return type int to long
FREQUENCY : always