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 191229 Details for
Bug 340029
[1.5][compiler] Enum constructor that throws Exception reports a confusing error message
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test
patch_340029.txt (text/plain), 4.63 KB, created by
Olivier Thomann
on 2011-03-15 13:27:08 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2011-03-15 13:27:08 EDT
Size:
4.63 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.422.2.15 >diff -u -r1.422.2.15 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 14 Mar 2011 18:59:56 -0000 1.422.2.15 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 15 Mar 2011 14:30:28 -0000 >@@ -3310,6 +3310,8 @@ > } > enumConstant.initialization = allocationExpression; > } >+ // initialize the starting position of the allocation expression >+ enumConstant.initialization.sourceStart = enumConstant.declarationSourceStart; > > // recovery > if (this.currentElement != null) { >@@ -3377,22 +3379,32 @@ > final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr]; > fieldDeclaration.declarationEnd = endOfEnumConstant; > fieldDeclaration.declarationSourceEnd = endOfEnumConstant; >+ // initialize the starting position of the allocation expression >+ ASTNode initialization = fieldDeclaration.initialization; >+ if (initialization != null) { >+ initialization.sourceEnd = endOfEnumConstant; >+ } > } > protected void consumeEnumConstants() { > concatNodeLists(); > } > protected void consumeEnumConstantWithClassBody() { >- dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]); >- TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type >- this.astLengthPtr--; >- anonymousType.bodyEnd = this.endPosition; >- anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); >- final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]); >- fieldDeclaration.declarationEnd = this.endStatementPosition; >- fieldDeclaration.declarationSourceEnd = anonymousType.declarationSourceEnd; >- this.intPtr --; // remove end position of the arguments >- this.variablesCounter[this.nestedType] = 0; >- this.nestedType--; >+ dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]); >+ TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type >+ this.astLengthPtr--; >+ anonymousType.bodyEnd = this.endPosition; >+ anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); >+ final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]); >+ fieldDeclaration.declarationEnd = this.endStatementPosition; >+ int declarationSourceEnd = anonymousType.declarationSourceEnd; >+ fieldDeclaration.declarationSourceEnd = declarationSourceEnd; >+ this.intPtr --; // remove end position of the arguments >+ this.variablesCounter[this.nestedType] = 0; >+ this.nestedType--; >+ ASTNode initialization = fieldDeclaration.initialization; >+ if (initialization != null) { >+ initialization.sourceEnd = declarationSourceEnd; >+ } > } > protected void consumeEnumDeclaration() { > // EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java,v >retrieving revision 1.155.2.1 >diff -u -r1.155.2.1 EnumTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 14 Mar 2011 19:00:21 -0000 1.155.2.1 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 15 Mar 2011 14:30:29 -0000 >@@ -33,7 +33,7 @@ > // All specified tests which does not belong to the class are skipped... > static { > // TESTS_NAMES = new String[] { "test000" }; >-// TESTS_NUMBERS = new int[] { 182 }; >+// TESTS_NUMBERS = new int[] { 185 }; > // TESTS_RANGE = new int[] { 21, 50 }; > } > public static Test suite() { >@@ -6664,4 +6664,27 @@ > customOptions, > null); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id= >+public void test185() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public enum X {\n" + >+ " A, B;\n" + >+ " private X() throws Exception {\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " A, B;\n" + >+ " ^\n" + >+ "Unhandled exception type Exception\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 2)\n" + >+ " A, B;\n" + >+ " ^\n" + >+ "Unhandled exception type Exception\n" + >+ "----------\n"); >+} > }
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 340029
: 191229