### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v retrieving revision 1.21 diff -u -r1.21 NullReferenceTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 22 Mar 2006 09:46:42 -0000 1.21 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 22 Mar 2006 10:59:46 -0000 @@ -34,6 +34,7 @@ static { // TESTS_NAMES = new String[] { "test011" }; // TESTS_NUMBERS = new int[] { 516 }; +// TESTS_NUMBERS = new int[] { 732 }; // TESTS_NUMBERS = new int[] { 2999 }; // TESTS_RANGE = new int[] { 2050, -1 }; // TESTS_RANGE = new int[] { 1, 2049 }; @@ -5300,6 +5301,103 @@ "----------\n"); } +// null analysis - for nested with break +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=129371 +public void test0732_for_nested_break() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(String doubt) {\n" + + " for(int i = 0; i < 10; i++) {\n" + + " String s = doubt;\n" + + " if(s != null) {\n" + + " for(int j = 0; j < 1; j++) {\n" + + " break;\n" + + " }\n" + + " s.length();\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n" + + "\n"}, + ""); +} + +// null analysis - for while with break +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=129371 +// variant +public void test0733_for_while_break() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(String doubt, boolean b) {\n" + + " for(int i = 0; i < 10; i++) {\n" + + " String s = doubt;\n" + + " if (s != null) {\n" + + " while (b) {\n" + + " break;\n" + + " }\n" + + " s.length();\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n" + + "\n"}, + ""); +} + +// null analysis - for while with break +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=129371 +// variant +public void test0734_for_while_break() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(String doubt, boolean b) {\n" + + " for(int i = 0; i < 10; i++) {\n" + + " String s = doubt;\n" + + " if (s != null) {\n" + + " do {\n" + + " break;\n" + + " } while (b);\n" + + " s.length();\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n" + + "\n"}, + ""); +} + +// null analysis - for nested with break +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=129371 +// variant +public void test0735_for_nested_break() { + if (COMPLIANCE_1_5.equals(this.complianceLevel)) { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(Object[] a, String doubt) {\n" + + " for(int i = 0; i < 10; i++) {\n" + + " String s = doubt;\n" + + " if(s != null) {\n" + + " for(Object o : a) {\n" + + " break;\n" + + " }\n" + + " s.length();\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n" + + "\n"}, + ""); + } +} + // null analysis -- switch public void test0800_switch() { this.runConformTest( #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java,v retrieving revision 1.57 diff -u -r1.57 WhileStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java 10 Feb 2006 15:37:01 -0000 1.57 +++ compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java 22 Mar 2006 10:59:48 -0000 @@ -143,7 +143,10 @@ // end of loop FlowInfo mergedInfo = FlowInfo.mergedOptimizedBranches( - loopingContext.initsOnBreak, + (loopingContext.initsOnBreak.tagBits & + FlowInfo.UNREACHABLE) != 0 ? + loopingContext.initsOnBreak : + flowInfo.addInitializationsFrom(loopingContext.initsOnBreak), // recover upstream null info isConditionOptimizedTrue, exitBranch, isConditionOptimizedFalse, Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java,v retrieving revision 1.57 diff -u -r1.57 ForStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 31 Jan 2006 11:19:01 -0000 1.57 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 22 Mar 2006 10:59:48 -0000 @@ -193,7 +193,10 @@ //end of loop FlowInfo mergedInfo = FlowInfo.mergedOptimizedBranches( - loopingContext.initsOnBreak, + (loopingContext.initsOnBreak.tagBits & + FlowInfo.UNREACHABLE) != 0 ? + loopingContext.initsOnBreak : + flowInfo.addInitializationsFrom(loopingContext.initsOnBreak), // recover upstream null info isConditionOptimizedTrue, exitBranch, isConditionOptimizedFalse, Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java,v retrieving revision 1.33 diff -u -r1.33 ForeachStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 27 Feb 2006 11:29:46 -0000 1.33 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 22 Mar 2006 10:59:48 -0000 @@ -143,7 +143,10 @@ loopingContext.complainOnDeferredNullChecks(currentScope, actionInfo); FlowInfo mergedInfo = FlowInfo.mergedOptimizedBranches( - loopingContext.initsOnBreak, + (loopingContext.initsOnBreak.tagBits & + FlowInfo.UNREACHABLE) != 0 ? + loopingContext.initsOnBreak : + flowInfo.addInitializationsFrom(loopingContext.initsOnBreak), // recover upstream null info false, exitBranch, false, Index: compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java,v retrieving revision 1.47 diff -u -r1.47 DoStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java 31 Jan 2006 11:19:01 -0000 1.47 +++ compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java 22 Mar 2006 10:59:48 -0000 @@ -107,7 +107,10 @@ // end of loop FlowInfo mergedInfo = FlowInfo.mergedOptimizedBranches( - loopingContext.initsOnBreak, + (loopingContext.initsOnBreak.tagBits & + FlowInfo.UNREACHABLE) != 0 ? + loopingContext.initsOnBreak : + flowInfo.addInitializationsFrom(loopingContext.initsOnBreak), // recover upstream null info isConditionOptimizedTrue, (condInfo.tagBits & FlowInfo.UNREACHABLE) == 0 ? flowInfo.addInitializationsFrom(condInfo.initsWhenFalse()) : condInfo,