Small compatibility fixes of Collections classes.
Change-Id: I22d0e49e1b1d92edb508d608674d9abe405d3162
diff --git a/tools/api-checker/config/gwt27_28userApi.conf b/tools/api-checker/config/gwt27_28userApi.conf
index 1ce0f43..44ce6ec 100644
--- a/tools/api-checker/config/gwt27_28userApi.conf
+++ b/tools/api-checker/config/gwt27_28userApi.conf
@@ -190,3 +190,22 @@
java.util.logging.Logger::log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;) OVERLOADED_METHOD_CALL
java.util.logging.Logger::severe(Ljava/lang/String;) OVERLOADED_METHOD_CALL
java.util.logging.Logger::warning(Ljava/lang/String;) OVERLOADED_METHOD_CALL
+
+# Added constructors to ConcurrentModificationException
+java.util.ConcurrentModificationException::ConcurrentModificationException(Ljava/lang/String;) OVERLOADED_METHOD_CALL
+
+# Made java.util.Arrays non-instantiable
+java.util.Arrays::Arrays() MISSING
+java.util.Arrays::equals(Ljava/lang/Object;) MISSING
+java.util.Arrays::finalize() MISSING
+java.util.Arrays::getClass() MISSING
+java.util.Arrays::hashCode() MISSING
+java.util.Arrays::toString() MISSING
+
+# Made java.util.Collections non-instantiable
+java.util.Collections::Collections() MISSING
+java.util.Collections::equals(Ljava/lang/Object;) MISSING
+java.util.Collections::finalize() MISSING
+java.util.Collections::getClass() MISSING
+java.util.Collections::hashCode() MISSING
+java.util.Collections::toString() MISSING
\ No newline at end of file
diff --git a/user/super/com/google/gwt/emul/java/util/AbstractSet.java b/user/super/com/google/gwt/emul/java/util/AbstractSet.java
index a2b6eca..0bf9468 100644
--- a/user/super/com/google/gwt/emul/java/util/AbstractSet.java
+++ b/user/super/com/google/gwt/emul/java/util/AbstractSet.java
@@ -27,6 +27,8 @@
public abstract class AbstractSet<E> extends AbstractCollection<E> implements
Set<E> {
+ protected AbstractSet() { }
+
@Override
public boolean equals(Object o) {
if (o == this) {
diff --git a/user/super/com/google/gwt/emul/java/util/Arrays.java b/user/super/com/google/gwt/emul/java/util/Arrays.java
index 4229fe6..9b3bcc1 100644
--- a/user/super/com/google/gwt/emul/java/util/Arrays.java
+++ b/user/super/com/google/gwt/emul/java/util/Arrays.java
@@ -61,7 +61,7 @@
private E[] array;
ArrayList(E[] array) {
- assert (array != null);
+ checkNotNull(array);
this.array = array;
}
@@ -1781,4 +1781,6 @@
nativeNumberSort(temp);
ArrayHelper.copy(temp, 0, array, fromIndex, toIndex - fromIndex);
}
+
+ private Arrays() { }
}
diff --git a/user/super/com/google/gwt/emul/java/util/Collections.java b/user/super/com/google/gwt/emul/java/util/Collections.java
index a2d9276..8acab17 100644
--- a/user/super/com/google/gwt/emul/java/util/Collections.java
+++ b/user/super/com/google/gwt/emul/java/util/Collections.java
@@ -1145,17 +1145,18 @@
return modified;
}
- public static <T> void reverse(List<T> l) {
+ @SuppressWarnings("unchecked")
+ public static void reverse(List<?> l) {
if (l instanceof RandomAccess) {
for (int iFront = 0, iBack = l.size() - 1; iFront < iBack; ++iFront, --iBack) {
Collections.swap(l, iFront, iBack);
}
} else {
- ListIterator<T> head = l.listIterator();
- ListIterator<T> tail = l.listIterator(l.size());
+ ListIterator head = l.listIterator();
+ ListIterator tail = l.listIterator(l.size());
while (head.nextIndex() < tail.previousIndex()) {
- T headElem = head.next();
- T tailElem = tail.previous();
+ Object headElem = head.next();
+ Object tailElem = tail.previous();
head.set(tailElem);
tail.set(headElem);
}
@@ -1232,12 +1233,12 @@
}
}
- public static <T> void shuffle(List<T> list) {
+ public static void shuffle(List<?> list) {
shuffle(list, RandomHolder.rnd);
}
@SuppressWarnings("unchecked")
- public static <T> void shuffle(List<T> list, Random rnd) {
+ public static void shuffle(List<?> list, Random rnd) {
if (list instanceof RandomAccess) {
for (int i = list.size() - 1; i >= 1; i--) {
swapImpl(list, i, rnd.nextInt(i + 1));
@@ -1248,10 +1249,10 @@
swapImpl(arr, i, rnd.nextInt(i + 1));
}
- ListIterator<T> it = list.listIterator();
+ ListIterator it = list.listIterator();
for (Object e : arr) {
it.next();
- it.set((T) e);
+ it.set(e);
}
}
}
@@ -1312,8 +1313,7 @@
return new UnmodifiableSortedMap<K, V>(map);
}
- public static <T> SortedSet<T> unmodifiableSortedSet(
- SortedSet<? extends T> set) {
+ public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> set) {
return new UnmodifiableSortedSet<T>(set);
}
@@ -1352,4 +1352,6 @@
a[i] = a[j];
a[j] = obj;
}
+
+ private Collections() { }
}
diff --git a/user/super/com/google/gwt/emul/java/util/ConcurrentModificationException.java b/user/super/com/google/gwt/emul/java/util/ConcurrentModificationException.java
index 976a536..4b73f9b 100644
--- a/user/super/com/google/gwt/emul/java/util/ConcurrentModificationException.java
+++ b/user/super/com/google/gwt/emul/java/util/ConcurrentModificationException.java
@@ -28,4 +28,12 @@
public ConcurrentModificationException(String message) {
super(message);
}
+
+ public ConcurrentModificationException(Throwable cause) {
+ super(cause);
+ }
+
+ public ConcurrentModificationException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/user/test/com/google/gwt/emultest/java/util/ArraysTest.java b/user/test/com/google/gwt/emultest/java/util/ArraysTest.java
index a9a79c7..8d72b3b 100644
--- a/user/test/com/google/gwt/emultest/java/util/ArraysTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/ArraysTest.java
@@ -111,6 +111,12 @@
*/
@SuppressWarnings("unchecked")
public void testAsList() {
+ try {
+ Arrays.asList((Object[]) null);
+ fail();
+ } catch (NullPointerException expected) {
+ }
+
// 0
Object[] test = {};
List result = Arrays.asList(test);