I use Region.findBest(Object... args) method and pass target images as args. Everything is working good when target images exist on the screen, but when not, this method throws an exception:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_101] at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_101] at org.sikuli.script.Region.findBest(Region.java:2549) ~[sikulixapi-1.1.1-SNAPSHOT.jar:na]
The Region.java:2549 line is:
mResult = mList.get(0);
I'm using sikulixapi-1.1.1-SNAPSHOT as java library, but as I see the problem exists also in latest sikulixapi minor versions.
Possible solutions
Add a list size check to findBest(Object... args) method to return null in this case. Or...
Return null instead of empty list in the private findAnyCollect(Object... args) method which findBest(Object... args) method uses.
Hello.
Problem
I use Region.findBest(Object... args) method and pass target images as args. Everything is working good when target images exist on the screen, but when not, this method throws an exception:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_101] at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_101] at org.sikuli.script.Region.findBest(Region.java:2549) ~[sikulixapi-1.1.1-SNAPSHOT.jar:na]
The Region.java:2549 line is:
mResult = mList.get(0);
I'm using sikulixapi-1.1.1-SNAPSHOT as java library, but as I see the problem exists also in latest sikulixapi minor versions.
Possible solutions