From 7eb710a806a6bace9ebc17aa6f8138364ae8ac5a Mon Sep 17 00:00:00 2001 From: Steve Hannah Date: Tue, 12 May 2015 16:58:46 -0700 Subject: [PATCH] Fixed ArrayOutOfBounds on binarySearch of empty list. https://github.com/konsoletyper/teavm/issues/110 --- .../main/java/org/teavm/classlib/java/util/TCollections.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java index 6816aea8e..b9417c35f 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java @@ -253,6 +253,9 @@ public class TCollections extends TObject { } int l = 0; int u = list.size() - 1; + if (u < 0) { + return -1; + } while (true) { int i = (l + u) / 2; T e = list.get(i);