classlib: minor exceptions fix for lists (#819)

This commit is contained in:
Ivan Hetman 2023-10-13 20:45:02 +03:00 committed by GitHub
parent 55d3adb7ae
commit 0b2d1428fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -70,7 +70,7 @@ public abstract class TAbstractList<E> extends TAbstractCollection<E> implements
@Override @Override
public boolean addAll(int index, TCollection<? extends E> c) { public boolean addAll(int index, TCollection<? extends E> c) {
if (index < 0 || index > size()) { if (index < 0 || index > size()) {
throw new TIllegalArgumentException(); throw new TIndexOutOfBoundsException();
} }
if (c.isEmpty()) { if (c.isEmpty()) {
return false; return false;

View File

@ -34,6 +34,9 @@ public class TArrayList<E> extends TAbstractList<E> implements TCloneable, TSeri
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public TArrayList(int initialCapacity) { public TArrayList(int initialCapacity) {
if (initialCapacity < 0) {
throw new IllegalArgumentException();
}
array = (E[]) new Object[initialCapacity]; array = (E[]) new Object[initialCapacity];
} }