Community
Participate
Working Groups
Using v_749, the following code doesn't compile: class A { class B<T> { T t; T getValue() { return t; } } } class C<T> extends A { } public class X { static C.B<Double> c = new C().new B<Double>(); public static void main(String[] args) { C.B<String> temp = new C().new B<String>(); String s = temp.getValue(); System.out.println(s); foo(bar()); } static C.B<? extends Number> bar() { return new C().new B<Integer>(); } static void foo(C.B<?> arg) { Object o = arg.getValue(); Double d = c.getValue(); System.out.println(o); System.out.println(d); } } giving these errors and warnings: ---------- 1. ERROR in D:\tests_sources\X.java (at line 14) static C.B<Double> c = new C().new B<Double>(); ^^^ The member type C.B<Double> must be qualified with a parameterized type, since it is not static ---------- 2. WARNING in D:\tests_sources\X.java (at line 14) static C.B<Double> c = new C().new B<Double>(); ^ C is a raw type. References to generic type C<T> should be parameterized ---------- 3. ERROR in D:\tests_sources\X.java (at line 14) static C.B<Double> c = new C().new B<Double>(); ^ The member type C.B<Double> must be qualified with a parameterized type, since it is not static ---------- 4. ERROR in D:\tests_sources\X.java (at line 17) C.B<String> temp = new C().new B<String>(); ^^^ The member type C.B<String> must be qualified with a parameterized type, since it is not static ---------- 5. WARNING in D:\tests_sources\X.java (at line 17) C.B<String> temp = new C().new B<String>(); ^ C is a raw type. References to generic type C<T> should be parameterized ---------- 6. ERROR in D:\tests_sources\X.java (at line 17) C.B<String> temp = new C().new B<String>(); ^ The member type C.B<String> must be qualified with a parameterized type, since it is not static ---------- 7. ERROR in D:\tests_sources\X.java (at line 23) static C.B<? extends Number> bar() { ^^^ The member type C.B<? extends Number> must be qualified with a parameterized type, since it is not static ---------- 8. WARNING in D:\tests_sources\X.java (at line 24) return new C().new B<Integer>(); ^ C is a raw type. References to generic type C<T> should be parameterized ---------- 9. ERROR in D:\tests_sources\X.java (at line 24) return new C().new B<Integer>(); ^ The member type C.B<Integer> must be qualified with a parameterized type, since it is not static ---------- 10. ERROR in D:\tests_sources\X.java (at line 27) static void foo(C.B<?> arg) { ^^^ The member type C.B<?> must be qualified with a parameterized type, since it is not static ---------- 10 problems (7 errors, 3 warnings) whereas this one compiles fine: class A { class B<T> { T t; T getValue() { return t; } } } public class X { static A.B<Double> c = new A().new B<Double>(); public static void main(String[] args) { A.B<String> temp = new A().new B<String>(); String s = temp.getValue(); System.out.println(s); foo(bar()); } static A.B<? extends Number> bar() { return new A().new B<Integer>(); } static void foo(A.B<?> arg) { Object o = arg.getValue(); Double d = c.getValue(); System.out.println(o); System.out.println(d); } } javac compiles both cases without reporting any error, not even a warning.
Created attachment 64713 [details] Proposed patch
Created attachment 64742 [details] Better patch
Created attachment 64743 [details] Proposed patch for 3.2.2
Added GenericTypeTest#test1124-1128 Released for 3.3M7
Released for 3.2 maintenance.
Verified for 3.3M7 with I20070427-0010