On Fri, 7 Apr 2023 12:22:03 GMT, Andy-Tatman <d...@openjdk.org> wrote:

> See https://bugs.java.com/bugdatabase/view_bug?bug_id=8305734

I realise this is a bit off-topic for this specific bug, but perhaps relevant 
for the specification: The size() function can already start to overflow with 
much smaller indices being set, due to how ensureCapacity(int) currently works.

`BitSet bitSet = new BitSet(0);`
`bitSet.set(Integer.MAX_VALUE/2);`
`System.out.println("size = " + bitSet.size());`
`bitSet.set(Integer.MAX_VALUE/2 + 64);`
`System.out.println("size = " + bitSet.size());`

The second size() call has already overflown, due to the fact that 
ensureCapacity always grows the words array to at least twice the original size.
Furthermore, my impression is that any bit over Integer.MAX_VALUE-64 being set 
will always cause size() to overflow.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13388#issuecomment-1519733075

Reply via email to