RFR: 8305734: BitSet.get(int, int) always returns the empty BitSet when the Integer.MAX VALUE is set
Stuart Marks
smarks at openjdk.org
Mon May 8 23:21:23 UTC 2023
On Fri, 7 Apr 2023 12:22:03 GMT, Andy-Tatman <duke at openjdk.org> wrote:
> See https://bugs.java.com/bugdatabase/view_bug?bug_id=8305734
Further notes on `size()`. See this comment in [JDK-4213570](https://bugs.openjdk.org/browse/JDK-4213570?focusedCommentId=12238736&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12238736). The size() method was introduced with BitSet itself in JDK 1.0. It was probably an error, as in those days people might not have understood the importance of APIs separate from implementation. In addition, as noted previously, size() has a bunch of bugs. The comment suggests that the length() method was introduced as a replacement for size(). The length() method has its own bugs, but it's clearly an attempt to provide a better abstraction than size(). Also note that the specification for length() describes it as the "logical size."
Maybe this means that size() should be deprecated. At least, it might mean that we have more of a free hand to remove some of its obvious misbehavior, such as what's described in [JDK-8230557](https://bugs.openjdk.org/browse/JDK-8230557?focusedCommentId=14573956&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14573956).
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13388#issuecomment-1539184723
More information about the core-libs-dev
mailing list