import java.util.BitSet; public class BitSetBug { public static void main(String[] args) { BitSet b = new BitSet(); b.set(Integer.MAX_VALUE); b.stream().count(); // throws IndexOutOfBoundsException } }