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

javac bug (JDK6): missing unchecked warning

XMLWordPrintable

    • x86
    • linux

      FULL PRODUCT VERSION :
      JDK6

      ADDITIONAL OS VERSION INFORMATION :
      All platforms

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      All configurations

      A DESCRIPTION OF THE PROBLEM :
      javac 1.6 give no unchecked warning on this:

      interface I1<T> {}
      final class GC33<T> implements I1<Short> {}

      class Z<T, U extends T, V extends Number> {
              GC33<Short> x = null;
              I1<V> y = (I1<V>)x;
      }

      We can tell that a GC33<Short> can be cast safely to an I1<Short>, but if V is something other than Short the cast to I1<V> is not valid.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the program and observe the absence of the required warning.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An unchecked warning is required by the JLS.
      ACTUAL -
      No warning is produced.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      The required warning message is not produced by the compiler.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      interface I1<T> {}
      final class GC33<T> implements I1<Short> {}

      class Z<T, U extends T, V extends Number> {
              GC33<Short> x = null;
              I1<V> y = (I1<V>)x;
      }
      ---------- END SOURCE ----------

            mcimadamore Maurizio Cimadamore
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: