On Fri, 14 Apr 2023 15:53:41 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> @AlanBateman >> It is a known issue that size() may return a negative integer, see >> [JDK-8230557](https://bugs.openjdk.org/browse/JDK-8230557), and the accepted >> workaround is to interpret the returned integer as an unsigned value and >> convert the output to a long. This same workaround works if a user would >> call length() with Integer.MAX_VALUE set. Changing the specification to >> reject setting Integer.MAX_VALUE may end up breaking the implementation of >> clients who rely on setting Integer.MAX_VALUE and use this workaround. >> >> Furthermore, the other methods (including ones that use length()) still >> function correctly whether or not the Integer.MAX_VALUE bit is set, except >> for get(int,int) as reported here. For example, clear(int, int) works as >> expected if Integer.MAX_VALUE is set as length() then is not called. >> Changing the specification to reject setting Integer.MAX_VALUE may break >> user code that use this bit and/or users that rely on the above workaround. >> >> So while changing the specifications is possible, it can potentially break >> existing clients. The change suggested in this pull request avoids this and >> instead fixes the internal bug of the get function locally, without >> affecting the other methods and without affecting existing clients. > >> So while changing the specifications is possible, it can potentially break >> existing clients. The change suggested in this pull request avoids this and >> instead fixes the internal bug of the get function locally, without >> affecting the other methods and without affecting existing clients. > > I think it will require re-visting the spec, maybe deprecating and/or > introducing new methods, it's unfortunate that this wasn't recognised in > JDK-8230557. > > Update: @stuart-marks has added a comment to JDK-8230557 on the workaround > that someone added to that issue in 2019. @AlanBateman I would be happy to fill out the CSR, but unfortunately I don't think I am able to currently as I'm not an author on OpenJDK and as such don't have a JBS account. (I reported the bug through the Oracle site, rather than through bugs.openjdk.org .) Would you be able to help out with this? ------------- PR Comment: https://git.openjdk.org/jdk/pull/13388#issuecomment-1518016687