src/share/classes/java/util/Collections.java

Print this page

        

@@ -3170,11 +3170,11 @@
     /**
      * The empty set (immutable).  This set is serializable.
      *
      * @see #emptySet()
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings("rawtypes")
     public static final Set EMPTY_SET = new EmptySet<>();
 
     /**
      * Returns the empty set (immutable).  This set is serializable.
      * Unlike the like-named field, this method is parameterized.

@@ -3269,14 +3269,17 @@
         // Preserves singleton property
         private Object readResolve() {
             return new EmptySortedSet<>();
         }
 
-        public Comparator comparator() {
+        @Override
+        public Comparator<? super E> comparator() {
             return null;
         }
 
+        @Override
+        @SuppressWarnings("unchecked")
         public SortedSet<E> subSet(Object fromElement, Object toElement) {
             Objects.requireNonNull(fromElement);
             Objects.requireNonNull(toElement);
 
             if (!(fromElement instanceof Comparable) ||

@@ -3292,45 +3295,49 @@
             }
 
             return emptySortedSet();
         }
 
+        @Override
         public SortedSet<E> headSet(Object toElement) {
             Objects.requireNonNull(toElement);
 
             if (!(toElement instanceof Comparable)) {
                 throw new ClassCastException();
             }
 
             return emptySortedSet();
         }
 
+        @Override
         public SortedSet<E> tailSet(Object fromElement) {
             Objects.requireNonNull(fromElement);
 
             if (!(fromElement instanceof Comparable)) {
                 throw new ClassCastException();
             }
 
             return emptySortedSet();
         }
 
+        @Override
         public E first() {
             throw new NoSuchElementException();
         }
 
+        @Override
         public E last() {
             throw new NoSuchElementException();
         }
     }
 
     /**
      * The empty list (immutable).  This list is serializable.
      *
      * @see #emptyList()
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings("rawtypes")
     public static final List EMPTY_LIST = new EmptyList<>();
 
     /**
      * Returns the empty list (immutable).  This list is serializable.
      *

@@ -3400,11 +3407,11 @@
      * The empty map (immutable).  This map is serializable.
      *
      * @see #emptyMap()
      * @since 1.3
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings("rawtypes")
     public static final Map EMPTY_MAP = new EmptyMap<>();
 
     /**
      * Returns the empty map (immutable).  This map is serializable.
      *

@@ -3683,10 +3690,11 @@
             if (element != null)
                 Arrays.fill(a, 0, n, element);
             return a;
         }
 
+        @SuppressWarnings("unchecked")
         public <T> T[] toArray(T[] a) {
             final int n = this.n;
             if (a.length < n) {
                 a = (T[])java.lang.reflect.Array
                     .newInstance(a.getClass().getComponentType(), n);

@@ -3729,10 +3737,11 @@
      * @return A comparator that imposes the reverse of the <i>natural
      *         ordering</i> on a collection of objects that implement
      *         the <tt>Comparable</tt> interface.
      * @see Comparable
      */
+    @SuppressWarnings("unchecked")
     public static <T> Comparator<T> reverseOrder() {
         return (Comparator<T>) ReverseComparator.REVERSE_ORDER;
     }
 
     /**