diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractList.java b/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractList.java index a84b4573b..773d6446b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractList.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractList.java @@ -70,7 +70,7 @@ public abstract class TAbstractList extends TAbstractCollection implements @Override public boolean addAll(int index, TCollection c) { if (index < 0 || index > size()) { - throw new TIllegalArgumentException(); + throw new TIndexOutOfBoundsException(); } if (c.isEmpty()) { return false; diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TArrayList.java b/classlib/src/main/java/org/teavm/classlib/java/util/TArrayList.java index 0cfed0e56..66bce7c0c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TArrayList.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TArrayList.java @@ -34,6 +34,9 @@ public class TArrayList extends TAbstractList implements TCloneable, TSeri @SuppressWarnings("unchecked") public TArrayList(int initialCapacity) { + if (initialCapacity < 0) { + throw new IllegalArgumentException(); + } array = (E[]) new Object[initialCapacity]; }