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

Compiler issuses [unchecked] warning without line number for anonymous inner classes.

XMLWordPrintable

    • generic
    • generic

      Tried on Solaris JDK build 1.6.0-ea-b35.

      Please see the following code
      <code>
      class Pair<X,Y> {
            Pair(X x) {
            }
            <X> void testMethod(X x) {
                Pair<String,String> y = new Pair("Hi Pair") {};
            }
      }
      </code>

      Output when compiled:
      <output>
      bash-2.05b$ $b/javac -Xlint Test31.java
      Test31.java:5: warning: [unchecked] unchecked call to Pair(X) as a member of the raw type Pair
                Pair<String,String> y = new Pair("Hi Pair"){};
                                        ^
      [unchecked] unchecked call to Pair(X) as a member of the raw type Pair
      Test31.java:5: warning: [unchecked] unchecked conversion
      found : <anonymous Pair>
      required: Pair<java.lang.String,java.lang.String>
                Pair<String,String> y = new Pair("Hi Pair"){};
                                        ^
      3 warnings
      </output>
      The second warning doesn't have line number and its duplicate of first.

      ###@###.### 2005-05-09 05:01:22 GMT
      ###@###.### 2005-05-09 05:38:39 GMT

            ahe Peter Ahe
            rgutupalsunw Rajendra Gutupalli (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: