Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6270087

Javac rejects legal cast

XMLWordPrintable

    • generic
    • generic

      In this program, only cast 3 should be rejected:

      import java.util.List;
      public class X<S extends Comparable<S>> {

         Object foo(Comparable<Integer> c) {
               return (Comparable<S>) c; // 1
         }

         <U extends Throwable, V extends Runnable> void foo(List<V> lv) {
               List l = (List<U>) lv; // 2
         }

         <U extends Throwable, V extends Runnable> void foo2(List<List<V>> lv) {
               List l = (List<List<U>>) lv; // 3
         }
      }

      ###@###.### 2005-05-13 15:51:12 GMT

            mcimadamore Maurizio Cimadamore
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: