I am migrating my java application from JDK8 to JDK11 but during migration one of my test is failing in java11. It is throwing Index -1 out of bounds for length 3 but this test is passing with JDK8.
According to ArrayIndexOutOfBoundsException java documentation nothing is changed in Java 8 and Java11 but still this test is failing. According to documentation if the index is negative number then program will throw ArrayIndexOutOfBoundsException. So for Java8 it is throwing ArrayIndexOutOfBoundsException and test is passing. In Java11 it is throwing IndexOutOfBoundsException instead of ArrayIndexOutOfBoundsException and failing my test. Attaching my stack-trace below:
Index -1 out of bounds for length 3
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 3
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
Any help in this regard will be appreciated.