diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TPriorityQueue.java b/classlib/src/main/java/org/teavm/classlib/java/util/TPriorityQueue.java index ad871ab1f..d43dcdd5f 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TPriorityQueue.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TPriorityQueue.java @@ -48,8 +48,8 @@ public class TPriorityQueue extends TAbstractQueue implements TSerializabl initFromSortedSet((TSortedSet) c); } else { data = new Object[c.size()]; - fillFromCollection(c); setComparator(null); + fillFromCollection(c); } } @@ -170,6 +170,9 @@ public class TPriorityQueue extends TAbstractQueue implements TSerializabl if (version != knownVersion) { throw new TConcurrentModificationException(); } + if (index >= size) { + throw new TNoSuchElementException(); + } removeIndex = index; return (E) data[index++]; }