On Tue, 24 Jun 2025 23:00:03 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
> > I think the check is to ensure the passed index parameter is to verify the > > boundary of text length. > > Yes, but the index passed to the method is `an index within the text`, so it > should be from 0 to length - 1. You can take a look at the opposite case when > the index is outside the range, for example at the beginning of the text and > getAfterIndex: > > > result = at.getAfterIndex(AccessibleText.CHARACTER, -1); > > verifyResult("T", result); > > Is that expectation correct or not? I think we should first decide whether > this is actually a bug or not. I got your point now. The spec says that `index an index within the text` and that means the value should range from 0 to length - 1. And that means, `getBeforeIndex` won't be able to fetch the last character and `getAfterIndex` won't be able to fetch the first character. So, if someone wants to retrieve the first or last character, they shouldn't rely on `getAfterIndex and getBeforeIndex` method respectively, rather use `getAtIndex` method to get the first and last character with index passed as 0 and length -1 respectively. Right ? ------------- PR Comment: https://git.openjdk.org/jdk/pull/25941#issuecomment-3003204161