Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 193140 Details for
Bug 340691
Syntax error leads to ClassCastException in ASTConverter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix + tests
patch340691.txt (text/plain), 7.50 KB, created by
Ayushman Jain
on 2011-04-13 05:54:00 EDT
(
hide
)
Description:
proposed fix + tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-04-13 05:54:00 EDT
Size:
7.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v >retrieving revision 1.425 >diff -u -r1.425 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 6 Apr 2011 22:26:03 -0000 1.425 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 13 Apr 2011 09:35:23 -0000 >@@ -1016,6 +1016,11 @@ > } > if (node instanceof TypeDeclaration){ > TypeDeclaration type = (TypeDeclaration) node; >+ if ((type.modifiers & ClassFileConstants.AccEnum) != 0) { >+ // do not allow enums to be build as recovery types >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=340691 >+ continue; >+ } > if (type.declarationSourceEnd == 0){ > element = element.add(type, 0); > this.lastCheckPoint = type.bodyStart; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java,v >retrieving revision 1.63 >diff -u -r1.63 DietRecoveryTest.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java 22 Apr 2010 04:39:01 -0000 1.63 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java 13 Apr 2011 09:35:29 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7619,19 +7619,12 @@ > "}\n"; > } else { > expectedDietPlusBodyPlusStatementsRecoveryUnitToString = >- "public class Test {\n" + >- " public Test() {\n" + >- " super();\n" + >- " }\n" + >- " void aMethod() {\n" + >- " public static @m1() enum $missing$ {\n" + >- " public $missing$() {\n" + >- " super();\n" + >- " }\n" + >- " <clinit>() {\n" + >- " }\n" + >- " }\n" + >- " }\n" + >+ "public class Test {\n" + >+ " public Test() {\n" + >+ " super();\n" + >+ " }\n" + >+ " void aMethod() {\n" + >+ " }\n" + > "}\n"; > } > >Index: src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java,v >retrieving revision 1.7 >diff -u -r1.7 StatementRecoveryTest_1_5.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java 27 Jun 2008 16:04:46 -0000 1.7 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java 13 Apr 2011 09:35:29 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -728,4 +728,65 @@ > expectedFullWithStatementRecoveryUnitToString, > testName); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340691 >+// Verify that we don't get a recovered enum declaration when the error token is after an >+// incorrectly used modifier >+public void test0008() { >+ String s = >+ "public class Try {\n" + >+ "\n" + >+ " void m() {\n" + >+ "\n" + >+ " synchronized new Object();\n" + >+ "\n" + >+ " }\n" + >+ "}\n" + >+ "\n"; >+ >+ String expectedDietUnitToString = >+ "public class Try {\n" + >+ " public Try() {\n" + >+ " }\n" + >+ " void m() {\n" + >+ " }\n" + >+ "}\n"; >+ >+ String expectedDietWithStatementRecoveryUnitToString = >+ expectedDietUnitToString; >+ >+ String expectedDietPlusBodyUnitToString = >+ "public class Try {\n" + >+ " public Try() {\n" + >+ " super();\n" + >+ " }\n" + >+ " void m() {\n" + >+ " }\n" + >+ "}\n"; >+ >+ String expectedDietPlusBodyWithStatementRecoveryUnitToString = >+ "public class Try {\n" + >+ " public Try() {\n" + >+ " super();\n" + >+ " }\n" + >+ " void m() {\n" + >+ " }\n" + >+ "}\n"; >+ >+ String expectedFullUnitToString = >+ expectedDietUnitToString; >+ >+ String expectedFullWithStatementRecoveryUnitToString = >+ expectedFullUnitToString; >+ >+ String testName = "test"; >+ checkParse( >+ s.toCharArray(), >+ expectedDietUnitToString, >+ expectedDietWithStatementRecoveryUnitToString, >+ expectedDietPlusBodyUnitToString, >+ expectedDietPlusBodyWithStatementRecoveryUnitToString, >+ expectedFullUnitToString, >+ expectedFullWithStatementRecoveryUnitToString, >+ testName); >+} > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java,v >retrieving revision 1.17 >diff -u -r1.17 ASTConverterRecoveryTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java 15 Nov 2010 19:21:40 -0000 1.17 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java 13 Apr 2011 09:35:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2010 IBM Corporation and others. >+ * Copyright (c) 2006, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -1077,4 +1077,34 @@ > checkSourceRange(anonymousClassDeclaration, "new Object() {hash}", source); //$NON-NLS-1$ > checkSourceRange(assignment, "field= new Object() {hash}", source); //$NON-NLS-1$ > } >+ >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=340691 >+ public void test0021() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Converter/src/test/X.java", >+ "package test;\n"+ >+ "public class X {\n"+ >+ " void foo() {\n" + >+ " synchronized new Object();\n" + >+ " }\n" + >+ "}\n"); >+ ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); >+ >+ assertASTNodeEquals( >+ "package test;\n" + >+ "public class X {\n" + >+ " void foo(){\n" + >+ " }\n" + >+ "}\n", >+ result); >+ >+ ASTNode node = getASTNode((CompilationUnit) result, 0, 0); >+ assertNotNull(node); >+ assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ >+ MethodDeclaration methodDeclaration = (MethodDeclaration) node; >+ Block block = methodDeclaration.getBody(); >+ List statements = block.statements(); >+ assertEquals("wrong size", 0, statements.size()); //$NON-NLS-1$ >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 340691
:
193087
| 193140