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 202347 Details for
Bug 356002
VerifyError "Inconsistent stackmap frames" for switch-string statement with nested for-loop
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed fix + regression tests (3.7.x)
patch_356002_37x.txt (text/plain), 7.43 KB, created by
Olivier Thomann
on 2011-08-29 13:24:21 EDT
(
hide
)
Description:
Proposed fix + regression tests (3.7.x)
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2011-08-29 13:24:21 EDT
Size:
7.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: buildnotes_jdt-core.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v >retrieving revision 1.7860.2.23 >diff -u -r1.7860.2.23 buildnotes_jdt-core.html >--- buildnotes_jdt-core.html 29 Aug 2011 16:39:41 -0000 1.7860.2.23 >+++ buildnotes_jdt-core.html 29 Aug 2011 17:23:17 -0000 >@@ -51,7 +51,9 @@ > <h2>What's new in this drop</h2> > > <h3>Problem Reports Fixed</h3> >-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350095">350095</a> >+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=356002">356002</a> >+VerifyError "Inconsistent stackmap frames" for switch-string statement with nested for-loop >+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350095">350095</a> > The 2000th (0-based) enum constant is null > > <a name="v_B75_R37x"></a> >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java,v >retrieving revision 1.79.4.1 >diff -u -r1.79.4.1 SwitchStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 28 Jul 2011 17:52:16 -0000 1.79.4.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 29 Aug 2011 17:23:17 -0000 >@@ -175,7 +175,6 @@ > } > > final boolean hasCases = this.caseCount != 0; >- final boolean valueRequired = this.expression.constant == Constant.NotAConstant || hasCases; > > StringSwitchCase [] stringCases = new StringSwitchCase[this.caseCount]; // may have to shrink later if multiple strings hash to same code. > BranchLabel[] sourceCaseLabels = new BranchLabel[this.caseCount]; >@@ -242,7 +241,7 @@ > codeStream.ifne(stringCases[i].label); > } > codeStream.goto_(defaultBranchLabel); >- } else if (valueRequired) { >+ } else { > codeStream.pop(); > } > >@@ -474,6 +473,15 @@ > expressionType = null; // fault-tolerance: ignore type mismatch from constants from hereon > } > } >+ if (isStringSwitch) { >+ // the secret variable should be created before iterating over the switch's statements that could >+ // create more locals. This must be done to prevent overlapping of locals >+ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=356002 >+ this.dispatchStringCopy = new LocalVariableBinding(SecretStringVariableName, upperScope.getJavaLangString(), ClassFileConstants.AccDefault, false); >+ upperScope.addLocalVariable(this.dispatchStringCopy); >+ this.dispatchStringCopy.setConstant(Constant.NotAConstant); >+ this.dispatchStringCopy.useFlag = LocalVariableBinding.USED; >+ } > if (this.statements != null) { > this.scope = new BlockScope(upperScope); > int length; >@@ -522,12 +530,6 @@ > upperScope.problemReporter().undocumentedEmptyBlock(this.blockStart, this.sourceEnd); > } > } >- if (isStringSwitch) { >- this.dispatchStringCopy = new LocalVariableBinding(SecretStringVariableName, upperScope.getJavaLangString(), ClassFileConstants.AccDefault, false); >- upperScope.addLocalVariable(this.dispatchStringCopy); >- this.dispatchStringCopy.setConstant(Constant.NotAConstant); >- this.dispatchStringCopy.useFlag = LocalVariableBinding.USED; >- } > // for enum switch, check if all constants are accounted for (if no default) > if (isEnumSwitch && this.defaultCase == null > && upperScope.compilerOptions().getSeverity(CompilerOptions.IncompleteEnumSwitch) != ProblemSeverities.Ignore) { >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java,v >retrieving revision 1.27.4.1 >diff -u -r1.27.4.1 SwitchTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java 28 Jul 2011 17:52:05 -0000 1.27.4.1 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java 29 Aug 2011 17:23:18 -0000 >@@ -30,6 +30,7 @@ > > static { > // TESTS_NUMBERS = new int[] { 22 }; >+// TESTS_NAMES = new String[] { "testFor356002", "testFor356002_2", "testFor356002_3" }; > } > public SwitchTest(String name) { > super(name); >@@ -2029,6 +2030,109 @@ > "DONE"); > } > } >+public void testFor356002() { >+ String errorMsg = >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " switch (foo()) {\n" + >+ " ^^^^^\n" + >+ "Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted\n" + >+ "----------\n"; >+ >+ String [] sourceFiles = >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private static String foo() {\n" + >+ " return \"\";\n" + >+ " }\n" + >+ " public static void main(String[] args) {\n" + >+ " switch (foo()) {\n" + >+ " default: {\n" + >+ " int j = 0;\n" + >+ " if (j <= 0)\n" + >+ " System.out.println(\"DONE\");\n" + >+ " }\n" + >+ " return;\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ }; >+ if (this.complianceLevel < JDKLevelSupportingStringSwitch) { >+ this.runNegativeTest(sourceFiles, errorMsg); >+ } else { >+ this.runConformTest(sourceFiles, "DONE"); >+ } >+} >+public void testFor356002_2() { >+ String errorMsg = >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " switch (\"\") {\n" + >+ " ^^\n" + >+ "Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted\n" + >+ "----------\n"; >+ >+ String [] sourceFiles = >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " switch (\"\") {\n" + >+ " default: {\n" + >+ " int j = 0;\n" + >+ " if (j <= 0)\n" + >+ " System.out.println(\"DONE\");\n" + >+ " }\n" + >+ " return;\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ }; >+ if (this.complianceLevel < JDKLevelSupportingStringSwitch) { >+ this.runNegativeTest(sourceFiles, errorMsg); >+ } else { >+ this.runConformTest(sourceFiles, "DONE"); >+ } >+} >+public void testFor356002_3() { >+ String errorMsg = >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " switch (foo()) {\n" + >+ " ^^^^^\n" + >+ "Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted\n" + >+ "----------\n"; >+ >+ String [] sourceFiles = >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private static String foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ " public static void main(String[] args) {\n" + >+ " try {\n" + >+ " switch (foo()) {\n" + >+ " default: {\n" + >+ " int j = 0;\n" + >+ " if (j <= 0)\n" + >+ " ;\n" + >+ " }\n" + >+ " return;\n" + >+ " }\n" + >+ " } catch(NullPointerException e) {\n" + >+ " System.out.println(\"DONE\");\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ }; >+ if (this.complianceLevel < JDKLevelSupportingStringSwitch) { >+ this.runNegativeTest(sourceFiles, errorMsg); >+ } else { >+ this.runConformTest(sourceFiles, "DONE"); >+ } >+} > public static Class testClass() { > return SwitchTest.class; > }
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 356002
:
202328
| 202347