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() {};
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() {};
- duplicates
-
JDK-6267097 Compiler issuses [unchecked] warning without line number for anonymous inner classes.
-
- Closed
-
- relates to
-
JDK-6253161 Incorrect position of serial warning in anonymous class
-
- Closed
-