> I found out that this code
>
> public class Main {
> public static void main(String[] args) {
> String s = "Hello world!";
> char[] chars = s.toCharArray();
> int point = Character.codePointAt(chars, -1, 1);
> }
> }
>
> throws `ArrayIndexOutOfBoundsException` instead of JavaDoc-specified
> `IndexOutOfBoundsException`:
>
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1
> out of bounds for length 12
> at java.base/java.lang.Character.codePointAtImpl(Character.java:9254)
> at java.base/java.lang.Character.codePointAt(Character.java:9249)
> at org.example.Main.main(Main.java:7)
>
> and the method doesn't check whether `index` parameter is negative:
>
> public static int codePointAt(char[] a, int index, int limit) {
> if (index >= limit || limit < 0 || limit > a.length) {
> throw new IndexOutOfBoundsException();
> }
> return codePointAtImpl(a, index, limit);
> }
>
> I suggest to check the `index` parameter explicitly instead of relying on
> AIOOBE thrown from accessing the array with negative index.
Sergey Tsypanov has updated the pull request incrementally with one additional
commit since the last revision:
8298033: Fix Character.codePointBefore()
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/11480/files
- new: https://git.openjdk.org/jdk/pull/11480/files/5ed82ac0..9a40f08c
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=11480&range=04
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=11480&range=03-04
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/11480.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/11480/head:pull/11480
PR: https://git.openjdk.org/jdk/pull/11480