Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336782

Summary: [1.7][recovery]Extra error tokens with invalid unary operator
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: CoreAssignee: Satyam Kandula <satyam.kandula>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, satyam.kandula
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch none

Description Ayushman Jain CLA 2011-02-10 01:56:02 EST
The following code snippet gives some extra error diagnostics when compiled in BETA_JAVA7 branch, as compared to when compiled with HEAD

public class GlobalVariables_1 {
	public static Object o;
	public static int i;
	static {
		try {
			o= new Object();
		} catch (Throwable e) {
			e.printStackTrace();
		}
		try {
			i= (1 + 1) *
                       (1 ++ 2);
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}
}

Extra errors are:
Pb(240) Syntax error, insert "}" to complete Block
Pb(240) Syntax error, insert "Finally" to complete TryStatement
Pb(235) Syntax error on token "1", invalid (
Pb(240) Syntax error, insert ";" to complete BlockStatements

This is illustrated by the failing test org.eclipse.jdt.core.tests.eval.NegativeVariableTest.testInitializerProblem() in BETA_JAVA7 branch.
Comment 1 Satyam Kandula CLA 2011-02-18 04:52:36 EST
Created attachment 189259 [details]
Patch

One new 1.7 grammar rule (CatchType ::= DisjunctiveType) get used also on 1.5, but their compliance in the grammar file has 1.7, causing the recovery to assume that it is illegal and thus the tests were failing.

Removed the compliance for this rule and other rule where the compliance was added 1.5, though it would get used in 1.3 too.
Comment 2 Satyam Kandula CLA 2011-02-18 04:55:30 EST
Released the grammar changes and the resource file that got updated on the java7 branch.
Comment 3 Ayushman Jain CLA 2011-06-29 06:08:57 EDT
Verified using Eclipse Java 7 Support(Beta) feature patch v20110623-0900.