| Summary: | [1.7] Add recovery in ASTConverter for all new constructs in JLS3 mode | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||
| Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | daniel_megert, deepakazad, jarthana, Olivier_Thomann | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | 3.7.1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
What behavior do you expect in the converter ? Changing title to reflect more what the problem is in this case. We need to add malformed nodes when we get nodes that correspond to Java 7 syntax in JLS3 mode. It should not fail with a UnsupportedOperationException exception, but the AST should contain MALFORMED node. Created attachment 191158 [details]
Proposed fix + regression tests
Released in BETA_JAVA7 branch. Verified. |
BETA_JAVA7 of jdt.core and jdt.ui package p; import java.io.*; public class Test17 { public static void main(String[] args) { File file = new File(args[0]); try { FileInputStream fis = new FileInputStream(file); fis.read(); } catch (FileNotFoundException | IOException e) { e.printStackTrace(); } } } Try to compile this class with the project set to use J2SE-1.6 or J2SE-1.7. In both cases, no exception must be thrown, since we never asked for a JLS4 AST. Of course, the example doesn't compile, since it uses a 1.7 language feature. java.lang.UnsupportedOperationException: Operation only supported in JLS4 AST at org.eclipse.jdt.core.dom.ASTNode.supportedOnlyIn4(ASTNode.java:1825) at org.eclipse.jdt.core.dom.DisjunctiveType.<init>(DisjunctiveType.java:94) at org.eclipse.jdt.core.dom.ASTConverter.convertType(ASTConverter.java:3403) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:788) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2648) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2487) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:536) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:187) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2766) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1279) at org.eclipse.jdt.core.dom.AST.convertCompilationUnit(AST.java:237) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:206) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1244) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.initialReconcile(JavaReconcilingStrategy.java:178) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.initialReconcile(CompositeReconcilingStrategy.java:114) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.initialReconcile(JavaCompositeReconcilingStrategy.java:136) at org.eclipse.jface.text.reconciler.MonoReconciler.initialProcess(MonoReconciler.java:105) at org.eclipse.jdt.internal.ui.text.JavaReconciler.initialProcess(JavaReconciler.java:406) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:173)