From a1906e8bbfa426ed1adfe751608bc74f1d4d2ab7 Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Wed, 19 Dec 2012 17:03:15 +0000 Subject: Import GNU Classpath (20121202). 2012-12-19 Matthias Klose Import GNU Classpath (20121202). * Regenerate class and header files. * Regenerate auto* files. * sources.am, gcj/javaprims.h: Regenerate. * gnu/java/nio/FileLockImpl.java (close): New override. From-SVN: r194618 --- libjava/classpath/java/util/Collections.java | 32 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'libjava/classpath/java/util/Collections.java') diff --git a/libjava/classpath/java/util/Collections.java b/libjava/classpath/java/util/Collections.java index 828c6ecea12..b970dd8f60a 100644 --- a/libjava/classpath/java/util/Collections.java +++ b/libjava/classpath/java/util/Collections.java @@ -120,10 +120,10 @@ public class Collections * @return an empty parameterized set. * @since 1.5 */ + @SuppressWarnings("unchecked") public static final Set emptySet() { - /* FIXME: Could this be optimized? */ - return new EmptySet(); + return (Set) EMPTY_SET; } /** @@ -161,6 +161,7 @@ public class Collections * @return A non-iterating iterator. */ // This is really cheating! I think it's perfectly valid, though. + @SuppressWarnings("unchecked") public Iterator iterator() { return (Iterator) EMPTY_LIST.iterator(); @@ -196,7 +197,7 @@ public class Collections */ public boolean equals(Object o) { - return o instanceof Set && ((Set) o).isEmpty(); + return o instanceof Set && ((Set) o).isEmpty(); } /** @@ -288,10 +289,10 @@ public class Collections * @return an empty parameterized list. * @since 1.5 */ + @SuppressWarnings("unchecked") public static final List emptyList() { - /* FIXME: Could this be optimized? */ - return new EmptyList(); + return (List) EMPTY_LIST; } /** @@ -369,7 +370,7 @@ public class Collections */ public boolean equals(Object o) { - return o instanceof List && ((List) o).isEmpty(); + return o instanceof List && ((List) o).isEmpty(); } /** @@ -480,10 +481,10 @@ public class Collections * @return an empty parameterized map. * @since 1.5 */ + @SuppressWarnings("unchecked") public static final Map emptyMap() { - /* FIXME: Could this be optimized? */ - return new EmptyMap(); + return (Map) EMPTY_MAP; } /** @@ -511,9 +512,10 @@ public class Collections * There are no entries. * @return The empty set. */ + @SuppressWarnings("unchecked") public Set> entrySet() { - return EMPTY_SET; + return (Set>) EMPTY_SET; } // The remaining methods are optional, but provide a performance @@ -546,7 +548,7 @@ public class Collections */ public boolean equals(Object o) { - return o instanceof Map && ((Map) o).isEmpty(); + return o instanceof Map && ((Map) o).isEmpty(); } /** @@ -572,9 +574,10 @@ public class Collections * No entries. * @return The empty set. */ + @SuppressWarnings("unchecked") public Set keySet() { - return EMPTY_SET; + return (Set) EMPTY_SET; } /** @@ -601,9 +604,10 @@ public class Collections * Collection, will work. Besides, that's what the JDK uses! * @return The empty set. */ + @SuppressWarnings("unchecked") public Collection values() { - return EMPTY_SET; + return (Collection) EMPTY_SET; } /** @@ -1854,7 +1858,7 @@ public class Collections public List subList(int from, int to) { if (from == to && (to == 0 || to == 1)) - return EMPTY_LIST; + return emptyList(); if (from == 0 && to == 1) return this; if (from > to) @@ -2480,7 +2484,7 @@ public class Collections * @throws ArrayStoreException if the type of any element of the * collection is not a subtype of the element type of a. */ - public T[] toArray(T[] a) + public E[] toArray(E[] a) { synchronized (mutex) { -- cgit v1.2.3