On Tue, 9 May 2023 00:12:19 GMT, Stuart Marks <sma...@openjdk.org> wrote:

> This isn't correct. When length() returns Integer.MIN_VALUE, this doesn't 
> _necessarily_ cause get(from, to) to always return an empty BitSet. Well, it 
> does in the current implementation, but that's simply a bug that can be 
> fixed. The implementation of the get() method can access the internal data of 
> the object and do the right thing, regardless of what the length() method 
> does. That change should probably be made, regardless of other spec changes 
> we've been discussing.

Noted, the opening paragraph of Problem should be corrected to the following:
"BitSet.length() returns a negative value when Integer.MAX_VALUE is set, such 
as by using the set(int) method or by passing large arrays to a BitSet 
constructor. This unexpected behaviour can cause issues where the user relies 
on length() returning a positive value or 0, such as the bug that occurs in the 
current implementation of get(int,int)."
This corrects the original paragraph, while still demonstrating why issues it 
can cause.

> Re disallowing bit Integer.MAX_VALUE: I have a feeling we can do better than 
> this.

That is fair enough. I will fill in the specification for the suggested CSR, so 
that the CSR can at least be properly discussed.

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

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

Reply via email to