Community
Participate
Working Groups
The Eclipse compiler does not complain about the following declaration: List<void[]> x = null; javac 1.5.0_06 gives the following errors: VoidArrayList.java:9: illegal start of type List<void[]> x = null; ^ VoidArrayList.java:9: > expected List<void[]> x = null; ^ VoidArrayList.java:9: not a statement List<void[]> x = null; ^ 3 errors
Good find.
We should revisit our error messages for void[] to only have one blaming the type reference directly, i.e. 'void[] is an invalid type' import java.util.*; public class X { List<void[]> x = null; void[] y; void[] foo(void[] arg) { void[] local; } }
import java.util.*; public class X { List<void[]> x = null; void[] y; void[] foo(void[] arg) { void[] local; Class c = void[].class; } }
import java.util.*; public class X { List<void[]> x = null; void[] y; void[] foo(void[] arg) { try { void[] local; Class c = void[].class; } catch(void[] e) { } } }
We also miss check on cast to (void[]) import java.util.*; public class X { List<void[]> x = null; void[] y; void[] foo(void[] arg) { try { void[] local = new void[0]; void[] local1 = new void[]{ null, null }; void[] local2 = { null, null }; System.out.println((void[]) null); Class c = void[].class; } catch(void[] e) { } } }
(In reply to comment #2) > We should revisit our error messages for void[] to only have one blaming the > type reference directly, i.e. 'void[] is an invalid type' Philippe, Do you prefer 'void[] is an invalid type' or 'An array of void is an invalid type'? I would vote for the first one.
Created attachment 53581 [details] Proposed fix
Created attachment 53582 [details] Regression tests
Released for 3.3M4.
Verified for 3.3 M4 using build I20061212-0010.