src/share/classes/sun/awt/util/IdentityLinkedList.java

Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:

@@ -278,11 +278,13 @@
         modCount++;
 
         Entry<E> successor = (index==size ? header : entry(index));
         Entry<E> predecessor = successor.previous;
         for (int i=0; i<numNew; i++) {
-            Entry<E> e = new Entry<E>((E)a[i], successor, predecessor);
+            @SuppressWarnings("unchecked")
+            E tmp = (E) a[i];
+            Entry<E> e = new Entry<E>(tmp, successor, predecessor);
             predecessor.next = e;
             predecessor = e;
         }
         successor.previous = predecessor;
 

@@ -394,11 +396,11 @@
      * @return the index of the first occurrence of the specified element in
      *         this list, or -1 if this list does not contain the element
      */
     public int indexOf(Object o) {
         int index = 0;
-        for (Entry e = header.next; e != header; e = e.next) {
+        for (Entry<E> e = header.next; e != header; e = e.next) {
             if (o == e.element) {
                 return index;
             }
             index++;
         }

@@ -416,11 +418,11 @@
      * @return the index of the last occurrence of the specified element in
      *         this list, or -1 if this list does not contain the element
      */
     public int lastIndexOf(Object o) {
         int index = size;
-        for (Entry e = header.previous; e != header; e = e.previous) {
+        for (Entry<E> e = header.previous; e != header; e = e.previous) {
             index--;
             if (o == e.element) {
                 return index;
             }
         }

@@ -785,11 +787,11 @@
     public Iterator<E> descendingIterator() {
         return new DescendingIterator();
     }
 
     /** Adapter to provide descending iterators via ListItr.previous */
-    private class DescendingIterator implements Iterator {
+    private class DescendingIterator implements Iterator<E> {
         final ListItr itr = new ListItr(size());
         public boolean hasNext() {
             return itr.hasPrevious();
         }
         public E next() {

@@ -858,10 +860,11 @@
      * @throws ArrayStoreException if the runtime type of the specified array
      *         is not a supertype of the runtime type of every element in
      *         this list
      * @throws NullPointerException if the specified array is null
      */
+    @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] a) {
         if (a.length < size)
             a = (T[])java.lang.reflect.Array.newInstance(
                                 a.getClass().getComponentType(), size);
         int i = 0;