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

Compiler issues two diagnostics for anonymous class, one is sufficient

    XMLWordPrintable

Details

    • generic
    • generic
    • Verified

    Description

      Tried on Linux - JDK build 1.6.0-auto-116
      Compiler issues wrong [unchecked] warning for anonymous inner classes.

      Please see the following code:
      <code>
      class A<T,K> {
          public A(K k) {}
      }

      public class Test26 {
          A a = new A("saaa") {
      public void getNoneTest() {}
      };
      }
      </code>

      Output of the code when compiled:
      <output>
      Test26.java:6: warning: [unchecked] unchecked call to A(K) as a member of the raw type A
          A a = new A("saaa") {
                ^
      Test26.java:7: warning: [unchecked] unchecked call to A(K) as a member of the raw type A
                  public void getNoneTest() {}
                              ^
      2 warnings
      </output>

      The second warning
      "warning: [unchecked] unchecked call to A(K) as a member of the raw type A
                  public void getNoneTest() {}" is wrong.

      ###@###.### 2005-05-02 05:31:27 GMT
      ###@###.### 2005-05-02 07:37:20 GMT
      It can also be errors:

       12 class T6231847 {
       13 interface T6231847I {}
       14 static class T6231847C {}
       15
       16 T6231847 t;
       17 Object o = new <Object> T6231847I() {};
       18 Object p = new T6231847I(o) {};
       19 Object q = t.new T6231847I() {};
       20 Object r = t.new <Object> T6231847I(o) {};
       21 Object s = t.new T6231847C() {};
       22 }

      T6231847.java:21: qualified new of static class
          Object s = t.new T6231847C() {};
                     ^
      T6231847.java:21: illegal qualifier; T6231847.T6231847C is not an inner class
          Object s = t.new T6231847C() {};

      Attachments

        Issue Links

          Activity

            People

              mcimadamore Maurizio Cimadamore
              savadhansunw Seetharama Avadhanam (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: