Community
Participate
Working Groups
Build ID: M20060921-0945 (3.2.1), but also seen in 3.3M3. Short description: if above of a non empty init block in local member type exists a field, then the init block doesn't have children. Example class: ----------- package P; public class X { void foo(){ class Y { String s = null; { class Z { } } } } void foo2(){ class Y { { class Z { } } String s = null; } } void foo3(){ class Y { { class Z { } } } } } ----- The init block inside of foo() shown as empty in the method outline of Java editor, but both other init blocks shown as non-empty. JUnit test case follows.
Created attachment 55374 [details] Patch against LocalElementTests.java version 1.11 Attached the patch for LocalElementTests version 1.11 from project org.eclipse.jdt.core.tests.model, R_3_2_1 branch. Three test cases added, and one of them fails with: junit.framework.ComparisonFailure: Unexpected compilation unit contents. ----------- Expected ------------ X.java\n class X\n void foo()\n class Y\n String s\n <initializer #1>\n class Z ------------ but was ------------ X.java\n class X\n void foo()\n class Y\n String s\n <initializer #1> --------- Difference is ---------- expected:<...\n class Z> but was:<...> ------- As one can see, <initializer #1> has no children, but should have class Z as a child.
Created attachment 55375 [details] Patch against LocalElementTests.java version 1.11 Attached the patch for LocalElementTests version 1.11 from project org.eclipse.jdt.core.tests.model, R_3_2_1 branch. Three test cases added, and one of them fails with: junit.framework.ComparisonFailure: Unexpected compilation unit contents. ----------- Expected ------------ X.java\n class X\n void foo()\n class Y\n String s\n <initializer #1>\n class Z ------------ but was ------------ X.java\n class X\n void foo()\n class Y\n String s\n <initializer #1> --------- Difference is ---------- expected:<...\n class Z> but was:<...> ------- As one can see, <initializer #1> has no children, but should have class Z as a child.
Created attachment 74013 [details] Proposed fix + regression test Parser resources need to be replaced with the second attachment
Created attachment 74014 [details] Parser resources Extract in the package org.eclipse.jdt.internal.compiler.parser
Released for 3.4M1. Regression tests added in org.eclipse.jdt.core.tests.model.LocalElementTests#testLocalType6 org.eclipse.jdt.core.tests.model.LocalElementTests#testLocalType7 org.eclipse.jdt.core.tests.model.LocalElementTests#testLocalType8 org.eclipse.jdt.core.tests.model.LocalElementTests#testLocalType9 org.eclipse.jdt.core.tests.model.LocalElementTests#testLocalType10
Verified for 3.4M1 using build I20070806-1800.