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

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr

@@ -283,10 +283,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)
             // Make a new array of a's runtime type, but my contents:
             return (T[]) Arrays.copyOf(elementData, size, a.getClass());
         System.arraycopy(elementData, 0, a, 0, size);

@@ -305,11 +306,13 @@
      * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public E get(int index) {
         rangeCheck(index);
 
-        return (E) elementData[index];
+        @SuppressWarnings("unchecked")
+        E rv = (E) elementData[index];
+        return rv;
     }
 
     /**
      * Replaces the element at the specified position in this list with
      * the specified element.

@@ -320,10 +323,11 @@
      * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public E set(int index, E element) {
         rangeCheck(index);
 
+        @SuppressWarnings("unchecked")
         E oldValue = (E) elementData[index];
         elementData[index] = element;
         return oldValue;
     }
 

@@ -369,10 +373,11 @@
      */
     public E remove(int index) {
         rangeCheck(index);
 
         modCount++;
+        @SuppressWarnings("unchecked")
         E oldValue = (E) elementData[index];
 
         int numMoved = size - index - 1;
         if (numMoved > 0)
             System.arraycopy(elementData, index+1, elementData, index,