View | Details | Raw Unified | Return to bug 328361 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java (-1 / +1 lines)
Lines 86-92 Link Here
86
		CompilerOptions compilerOptions = currentScope.compilerOptions();
86
		CompilerOptions compilerOptions = currentScope.compilerOptions();
87
		if (!compilerOptions.includeNullInfoFromAsserts) {
87
		if (!compilerOptions.includeNullInfoFromAsserts) {
88
			// keep just the initializations info, don't include assert's null info
88
			// keep just the initializations info, don't include assert's null info
89
			return flowInfo.addInitializationsFrom(assertInfo.nullInfoLessUnconditionalCopy());
89
			return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy());
90
		}
90
		}
91
		return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()).
91
		return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()).
92
			addInitializationsFrom(assertWhenTrueInfo.discardInitializationInfo());
92
			addInitializationsFrom(assertWhenTrueInfo.discardInitializationInfo());
(-)Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java (-2 / +106 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-21 Link Here
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.jdt.core.ToolFactory;
17
import org.eclipse.jdt.core.ToolFactory;
18
import org.eclipse.jdt.core.tests.compiler.regression.*;
18
import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest;
19
import org.eclipse.jdt.core.tests.util.Util;
19
import org.eclipse.jdt.core.tests.util.Util;
20
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
20
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
Lines 6253-6258 Link Here
6253
		},
6253
		},
6254
		"");
6254
		"");
6255
}
6255
}
6256
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
6257
public void test205() throws Exception {
6258
	if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
6259
		this.runNegativeTest(
6260
			new String[] {
6261
				"X.java",
6262
				"public class X {\n" +
6263
				"    static final int i;\n" +	
6264
				"    static {\n" +	
6265
				"        assert (i = 0) == 0;\n" +	
6266
				"        System.out.println(i);\n" +	
6267
				"    }\n" +	
6268
				"}\n"	
6269
			},
6270
			"----------\n" + 
6271
			"1. ERROR in X.java (at line 2)\n" + 
6272
			"	static final int i;\n" + 
6273
			"	                 ^\n" + 
6274
			"The blank final field i may not have been initialized\n" + 
6275
			"----------\n" + 
6276
			"2. ERROR in X.java (at line 5)\n" + 
6277
			"	System.out.println(i);\n" + 
6278
			"	                   ^\n" + 
6279
			"The blank final field i may not have been initialized\n" + 
6280
			"----------\n");
6281
	}
6282
}
6283
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
6284
public void test206() throws Exception {
6285
	if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
6286
		this.runNegativeTest(
6287
			new String[] {
6288
				"X.java",
6289
				"public class X {\n" +
6290
				"    void method1() {\n" +
6291
				"		 int i;" +	
6292
				"        assert (i = 0) == 0;\n" +	
6293
				"        System.out.println(i);\n" +	
6294
				"    }\n" +	
6295
				"}\n"	
6296
			},
6297
			"----------\n" + 
6298
			"1. ERROR in X.java (at line 4)\n" + 
6299
			"	System.out.println(i);\n" + 
6300
			"	                   ^\n" + 
6301
			"The local variable i may not have been initialized\n" + 
6302
			"----------\n");
6303
	}
6304
}
6305
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
6306
public void test207() throws Exception {
6307
	if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
6308
		this.runNegativeTest(
6309
			new String[] {
6310
				"X.java",
6311
				"public class X {\n" +
6312
				"	public int bar() {\n" +
6313
				"		return 1;\n" +
6314
				"	}\n" +
6315
				"    void method1() {\n" +
6316
				"		 int i;" +	
6317
				"        assert (i = this.bar()) == 0;\n" +	
6318
				"        System.out.println(i);\n" +	
6319
				"    }\n" +	
6320
				"}\n"	
6321
			},
6322
			"----------\n" + 
6323
			"1. ERROR in X.java (at line 7)\n" + 
6324
			"	System.out.println(i);\n" + 
6325
			"	                   ^\n" + 
6326
			"The local variable i may not have been initialized\n" + 
6327
			"----------\n");
6328
	}
6329
}
6330
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
6331
public void test208() throws Exception {
6332
	if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
6333
		this.runNegativeTest(
6334
			new String[] {
6335
				"X.java",
6336
				"public class X {\n" +
6337
				"	public int bar() {\n" +
6338
				"		return 1;\n" +
6339
				"	}\n" +
6340
				"    void method1() {\n" +
6341
				"		 int i;\n" +	
6342
				"        assert i++ == 0;\n" +	
6343
				"        System.out.println(i);\n" +	
6344
				"    }\n" +	
6345
				"}\n"	
6346
			},
6347
			"----------\n" + 
6348
			"1. ERROR in X.java (at line 7)\n" + 
6349
			"	assert i++ == 0;\n" + 
6350
			"	       ^\n" + 
6351
			"The local variable i may not have been initialized\n" + 
6352
			"----------\n" + 
6353
			"2. ERROR in X.java (at line 8)\n" + 
6354
			"	System.out.println(i);\n" + 
6355
			"	                   ^\n" + 
6356
			"The local variable i may not have been initialized\n" + 
6357
			"----------\n");
6358
	}
6359
}
6256
public static Class testClass() {
6360
public static Class testClass() {
6257
	return InitializationTest.class;
6361
	return InitializationTest.class;
6258
}
6362
}

Return to bug 328361