From 0b2d1428fb6777e01ed5a601218d8f0a5ce8fa27 Mon Sep 17 00:00:00 2001 From: Ivan Hetman Date: Fri, 13 Oct 2023 20:45:02 +0300 Subject: [PATCH] classlib: minor exceptions fix for lists (#819) --- .../main/java/org/teavm/classlib/java/util/TAbstractList.java | 2 +- .../src/main/java/org/teavm/classlib/java/util/TArrayList.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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]; }