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

Incorrect unchecked warning involving local class

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 6u14
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      javac 1.6.0_14-b08)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.18-92.1.22.el5
      Mac OS X 10.5.6

      A DESCRIPTION OF THE PROBLEM :
      I get an unchecked warning when an assignment conversion from a non-parameterized local class type to a parameterized supertype occurs.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the program below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should compile without warning.
      ACTUAL -
      Produces an unchecked warning. Note that only the local class type leads to a warning; the identical member class does not cause a warning.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      NoTypeArg.java:8: warning: [unchecked] unchecked conversion
      found : Instance2
      required: NoTypeArg.Foo<T>
          f = new Instance2(); // unchecked warning
       

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class NoTypeArg<T> {
        interface Foo<T> {}
        class Instance1 implements Foo<T> {}
        public void method() {
          class Instance2 implements Foo<T> {}
          Foo<T> f;
          f = new Instance1(); // no problem
          f = new Instance2(); // unchecked warning
        }
      }


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a SuppressWarnings tag, or a previous compiler.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: