Bug 5940

Summary: Instance initializer in anon inner class generates errors
Product: [Eclipse Project] JDT Reporter: Chris Smith <cdsmith0425>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M1   
Hardware: PC   
OS: Windows 98   
Whiteboard:

Description Chris Smith CLA 2001-11-14 21:01:35 EST
Compiling the following code:

public class Test
{
	Object t;

	private void testMethod()
	{
		t = new Object() {
			{
			}
		};
	}
}

Under the Eclipse environment produces this error:

The operator unknown operator is undefined for the argument type(s) 
java.lang.Object, <anonymous subclass of java.lang.Object>

By my interpretation of the JLS, this should be legal.  The Sun javac compiler 
compiles it without problems in versions 1.1.8, 1.3, and 1.4 beta 3.  
Incidentally, changing t, in the example above, to be a local variable removes 
the error and allows the code to compile successfully.
Comment 1 Philipe Mulet CLA 2001-11-15 08:33:51 EST
This is actually a bug in our Parser, reducing incorrectly the assignment to 
the anonymous type instance.

The bug disappears if removing the initializer nested inside. After analysis, 
it appears that the int stack of the parser is left inconsistent after the 
initializer got consumed, and the initializer start position is left on it.

However, the assignment operator code is supposed to be on top of the stack 
when reducing the assignment, leading to an unknown operator error afterwards.