Community
Participate
Working Groups
A field declaration with a generic type and trailing brackets and multiple fragements does not parse correctly: e.g.: public java.util.List<Integer> i[],j,k; or public java.util.List<Integer> i,j[]; class T { public java.util.List<Integer> i,j[],k; void m() { i[0] = null; // OK but should not be j[0] = null; k[0] = null; // OK but should not be } } The parser considers the type common to all the fragments to be an array type. This does not happen if the common type is a primitive type or a non-generic reference type. It does happen no matter which fragment the brackets are on. One can see the error by looking at the resulting AST as well, though interestingly, the AST appears correct for the case above, but is clearly wrong for the case where the brackets are on j. I would try to debug this further, but the parser is table driven and I do not know where the files that create the tables are. Here is what I get from printing out the AST for some examples: TREES FOR class T { public java.util.List<Integer> i,j[]; } ECLIPSE AST 0) class org.eclipse.jdt.core.dom.CompilationUnit 0 49 1) class org.eclipse.jdt.core.dom.TypeDeclaration 0 49 2) class org.eclipse.jdt.core.dom.SimpleName 6 1 3) class org.eclipse.jdt.core.dom.FieldDeclaration 10 37 4) class org.eclipse.jdt.core.dom.Modifier 10 6 5) class org.eclipse.jdt.core.dom.ArrayType 17 23 <--- should not be an array of parameterized type 6) class org.eclipse.jdt.core.dom.ParameterizedType 17 23 7) class org.eclipse.jdt.core.dom.SimpleType 17 14 8) class org.eclipse.jdt.core.dom.QualifiedName 17 14 9) class org.eclipse.jdt.core.dom.QualifiedName 17 9 10) class org.eclipse.jdt.core.dom.SimpleName 17 4 11) class org.eclipse.jdt.core.dom.SimpleName 22 4 12) class org.eclipse.jdt.core.dom.SimpleName 27 4 13) class org.eclipse.jdt.core.dom.SimpleType 32 7 14) class org.eclipse.jdt.core.dom.SimpleName 32 7 15) class org.eclipse.jdt.core.dom.VariableDeclarationFragment 41 1 16) class org.eclipse.jdt.core.dom.SimpleName 41 1 17) class org.eclipse.jdt.core.dom.VariableDeclarationFragment 43 3 18) class org.eclipse.jdt.core.dom.SimpleName 43 1 This one looks ok, but the type for j is still incorrectly an array type. TREES FOR class T { public java.util.List<Integer> i[],j; } ECLIPSE AST 0) class org.eclipse.jdt.core.dom.CompilationUnit 0 49 1) class org.eclipse.jdt.core.dom.TypeDeclaration 0 49 2) class org.eclipse.jdt.core.dom.SimpleName 6 1 3) class org.eclipse.jdt.core.dom.FieldDeclaration 10 37 4) class org.eclipse.jdt.core.dom.Modifier 10 6 5) class org.eclipse.jdt.core.dom.ParameterizedType 17 23 6) class org.eclipse.jdt.core.dom.SimpleType 17 14 7) class org.eclipse.jdt.core.dom.QualifiedName 17 14 8) class org.eclipse.jdt.core.dom.QualifiedName 17 9 9) class org.eclipse.jdt.core.dom.SimpleName 17 4 10) class org.eclipse.jdt.core.dom.SimpleName 22 4 11) class org.eclipse.jdt.core.dom.SimpleName 27 4 12) class org.eclipse.jdt.core.dom.SimpleType 32 7 13) class org.eclipse.jdt.core.dom.SimpleName 32 7 14) class org.eclipse.jdt.core.dom.VariableDeclarationFragment 41 3 15) class org.eclipse.jdt.core.dom.SimpleName 41 1 16) class org.eclipse.jdt.core.dom.VariableDeclarationFragment 45 1 17) class org.eclipse.jdt.core.dom.SimpleName 45 1 - David
The fix is simple. We wrongly shared the type reference in the copyDims(int) method on the parameterized single type reference and parameterized qualified type reference. Philippe, I believe this is a must fix for 3.1.1.
Fixed and released in HEAD. Regression tests added in GenericTypeTest.test793/794
Created attachment 25583 [details] Proposed fix
+1 for 3.1.1
Backported to 3.1 maintenance stream. Regression tests added in GenericTypeTest.test793/794
Verified with 3.2 M1
Verified for 3.2 M2 on build Build id: I20050920-0010.
Verified using M20050923-1430 for 3.1.1