Community
Participate
Working Groups
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.
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.