### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java,v retrieving revision 1.65 diff -u -r1.65 AssertStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 29 Sep 2010 16:43:28 -0000 1.65 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 21 Oct 2010 19:17:40 -0000 @@ -86,7 +86,7 @@ CompilerOptions compilerOptions = currentScope.compilerOptions(); if (!compilerOptions.includeNullInfoFromAsserts) { // keep just the initializations info, don't include assert's null info - return flowInfo.addInitializationsFrom(assertInfo.nullInfoLessUnconditionalCopy()); + return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()); } return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()). addInitializationsFrom(assertWhenTrueInfo.discardInitializationInfo()); #P org.eclipse.jdt.core.tests Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java =================================================================== RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java,v retrieving revision 1.128 diff -u -r1.128 InitializationTest.java --- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 27 May 2010 14:12:25 -0000 1.128 +++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 21 Oct 2010 19:17:43 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -15,7 +15,7 @@ import java.util.Map; import org.eclipse.jdt.core.ToolFactory; -import org.eclipse.jdt.core.tests.compiler.regression.*; +import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; @@ -6253,6 +6253,110 @@ }, ""); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 +public void test205() throws Exception { + if (this.complianceLevel >= ClassFileConstants.JDK1_5) { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " static final int i;\n" + + " static {\n" + + " assert (i = 0) == 0;\n" + + " System.out.println(i);\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " static final int i;\n" + + " ^\n" + + "The blank final field i may not have been initialized\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " System.out.println(i);\n" + + " ^\n" + + "The blank final field i may not have been initialized\n" + + "----------\n"); + } +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 +public void test206() throws Exception { + if (this.complianceLevel >= ClassFileConstants.JDK1_5) { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void method1() {\n" + + " int i;" + + " assert (i = 0) == 0;\n" + + " System.out.println(i);\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " System.out.println(i);\n" + + " ^\n" + + "The local variable i may not have been initialized\n" + + "----------\n"); + } +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 +public void test207() throws Exception { + if (this.complianceLevel >= ClassFileConstants.JDK1_5) { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public int bar() {\n" + + " return 1;\n" + + " }\n" + + " void method1() {\n" + + " int i;" + + " assert (i = this.bar()) == 0;\n" + + " System.out.println(i);\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " System.out.println(i);\n" + + " ^\n" + + "The local variable i may not have been initialized\n" + + "----------\n"); + } +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 +public void test208() throws Exception { + if (this.complianceLevel >= ClassFileConstants.JDK1_5) { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public int bar() {\n" + + " return 1;\n" + + " }\n" + + " void method1() {\n" + + " int i;\n" + + " assert i++ == 0;\n" + + " System.out.println(i);\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " assert i++ == 0;\n" + + " ^\n" + + "The local variable i may not have been initialized\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " System.out.println(i);\n" + + " ^\n" + + "The local variable i may not have been initialized\n" + + "----------\n"); + } +} public static Class testClass() { return InitializationTest.class; }