aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-05-29 10:24:31 (EDT)
committerAyushman Jain2012-05-29 10:24:31 (EDT)
commitee3dfd8d808b314a45a2da4f8014d314b68011f8 (patch)
tree3e2103adfaaf128648c0f1b2e359a747cc7dfeaa
parented6be0a94093e63f3ba13a0769b90a8ca2a5b2b0 (diff)
downloadeclipse.jdt.core-ee3dfd8d808b314a45a2da4f8014d314b68011f8.zip
eclipse.jdt.core-ee3dfd8d808b314a45a2da4f8014d314b68011f8.tar.gz
eclipse.jdt.core-ee3dfd8d808b314a45a2da4f8014d314b68011f8.tar.bz2
Fixed bug 380750: [compiler] local incorrectly flagged as uninitializedv20120529-1424
due to fix for bug 359495
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java23
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java3
3 files changed, 28 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
index b5dc253..56b2ce3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
@@ -2579,6 +2579,29 @@ public void testBug380313b() {
},
"");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=380750
+// verify that s0 is not reported as uninitialized
+public void testBug380750() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(String[] args) {\n" +
+ " String s0;\n" +
+ " for(String s : singleton(s0=\"\")) {\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ " System.out.println(s0);\n" +
+ " }\n" +
+ " String[] singleton(String s) {\n" +
+ " return new String[] {s};\n" +
+ " }\n" +
+ "}\n"
+ },
+ "");
+}
public static Class testClass() {
return FlowAnalysisTest.class;
}
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 88424f2..4fcd104 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -52,7 +52,9 @@ Eclipse SDK 3.8.0 - %date% - 3.8.0
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380313">380313</a>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380750">380750</a>
+[compiler] local incorrectly flagged as uninitialized due to fix for bug 359495
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380313">380313</a>
Inconsistent stack error when using Java 1.7
<a name="v_C56"></a>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
index 85ee809..4456f6e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
@@ -121,7 +121,7 @@ public class ForeachStatement extends Statement {
// code generation can be optimized when no need to continue in the loop
exitBranch = flowInfo.unconditionalCopy().
- addNullInfoFrom(condInfo.initsWhenFalse());
+ addInitializationsFrom(condInfo.initsWhenFalse());
// TODO (maxime) no need to test when false: can optimize (same for action being unreachable above)
if ((actionInfo.tagBits & loopingContext.initsOnContinue.tagBits &
FlowInfo.UNREACHABLE_OR_DEAD) != 0) {
@@ -169,6 +169,7 @@ public class ForeachStatement extends Statement {
exitBranch,
false,
true /*for(;;){}while(true); unreachable(); */);
+ mergedInfo.resetAssignmentInfo(this.elementVariable.binding);
this.mergedInitStateIndex = currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
}