code: @SuppressWarnings({"rawtypes", "unchecked"})
      public static void reverse(List<?> list) {
          int size = list.size();
          if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) {
              for (int i=0, mid=size>>1, j=size-1; i<mid; i++, j--)
                  swap(list, i, j);
          } else {
              // instead of using a raw type here, it's possible to capture
              // the wildcard but it will require a call to a supplementary
              // private method
              ListIterator fwd = list.listIterator();
              ListIterator rev = list.listIterator(size);
              for (int i=0, mid=list.size()>>1; i<mid; i++) {
                  Object tmp = fwd.next();
                  fwd.set(rev.previous());
                  rev.set(tmp);
              }
          }
      }
docs: Reverses the order of the elements in the specified list.<p>
  
  This method runs in linear time.
  
  @param  list the list whose elements are to be reversed.
  @throws UnsupportedOperationException if the specified list or
  its list-iterator does not support the <tt>set</tt> operation.