### 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:55:51 -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.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java,v retrieving revision 1.23 diff -u -r1.23 AssertionTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java 17 Aug 2009 17:46:06 -0000 1.23 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java 21 Oct 2010 19:55:52 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 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 @@ -507,5 +507,114 @@ "The local variable error6 may not have been initialized\n" + "----------\n"); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 + public void test018() { + 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" + + "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 test019() { + this.runConformTest(new String[] { + "X.java", + "public class X {\n" + + " static final int i;\n" + + " static {\n" + + " i = 0;\n" + + " assert i == 0;\n" + + " System.out.println(i);\n" + + " }\n" + + "}" + }, + ""); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 + public void test020() throws Exception { + 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 test021() throws Exception { + 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 test022() throws Exception { + 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"); + } }