Bug 159939 - [1.5][compiler] Eclipse allows List<void[]>, javac doesn't
Summary: [1.5][compiler] Eclipse allows List<void[]>, javac doesn't
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.3 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-05 17:25 EDT by Christopher Sahnwaldt CLA
Modified: 2006-12-12 13:28 EST (History)
2 users (show)

See Also:


Attachments
Proposed fix (21.33 KB, patch)
2006-11-09 15:20 EST, Olivier Thomann CLA
no flags Details | Diff
Regression tests (12.76 KB, patch)
2006-11-09 15:20 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Sahnwaldt CLA 2006-10-05 17:25:07 EDT
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
Comment 1 Philipe Mulet CLA 2006-10-05 17:55:57 EDT
Good find.
Comment 2 Philipe Mulet CLA 2006-10-31 05:08:44 EST
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;
	}
}
Comment 3 Philipe Mulet CLA 2006-10-31 05:09:44 EST
import java.util.*;
public class X {
	List<void[]> x = null;
	void[] y;
	void[] foo(void[] arg) {
		void[] local;
		Class c = void[].class;
	}
}
Comment 4 Philipe Mulet CLA 2006-10-31 05:10:40 EST
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) {
		}
	}
}
Comment 5 Philipe Mulet CLA 2006-10-31 05:14:39 EST
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) {
		}
	}
}
Comment 6 Olivier Thomann CLA 2006-11-09 10:49:17 EST
(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.
Comment 7 Olivier Thomann CLA 2006-11-09 15:20:14 EST
Created attachment 53581 [details]
Proposed fix
Comment 8 Olivier Thomann CLA 2006-11-09 15:20:30 EST
Created attachment 53582 [details]
Regression tests
Comment 9 Olivier Thomann CLA 2006-11-09 16:20:22 EST
Released for 3.3M4.
Comment 10 Frederic Fusier CLA 2006-12-12 13:28:58 EST
Verified for 3.3 M4 using build I20061212-0010.