On Wed, 1 Mar 2023 18:54:09 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> Raffaello Giulietti has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8302590: Add String.indexOf(int ch, int fromIndex, int toIndex) > > src/java.base/share/classes/java/lang/String.java line 2435: > >> 2433: * @apiNote >> 2434: * An invocation of this method returns -1 when {@code fromIndex} >> happens >> 2435: * to be too large. The result is thus indistinguishable from a >> genuine > > Adding an apiNote to the existing indexOf(int, int) is good but I think it > will need a bit word smithing, e.g. "happens to be too large" is a bit too > casual. I think I would start with saying the method returns -1 if fromFrom > is negative or >= the string length, it does not throw an exception if called > with an out of range index. Done. (A negative `fromIndex` does not necessarily result in -1, though.) > src/java.base/share/classes/java/lang/String.java line 2484: > >> 2482: * is negative, or {@code toIndex} is larger than the >> length of >> 2483: * this {@code String} object, or {@code fromIndex} is >> larger than >> 2484: * {@code toIndex}. > > Thanks for the update, I think you've got to a good place. @stuart-marks was quite convincing ;-) ------------- PR: https://git.openjdk.org/jdk/pull/12600