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());
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java (-3 / +137 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 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 17-23 Link Here
17
//	 All specified tests which does not belong to the class are skipped...
17
//	 All specified tests which does not belong to the class are skipped...
18
	static {
18
	static {
19
//		TESTS_NAMES = new String[] { "test000" };
19
//		TESTS_NAMES = new String[] { "test000" };
20
//		TESTS_NUMBERS = new int[] { 13, 14 };
20
//		TESTS_NUMBERS = new int[] { 18, 19 };
21
//		TESTS_RANGE = new int[] { 11, -1 };
21
//		TESTS_RANGE = new int[] { 11, -1 };
22
	}
22
	}
23
	public AssertionTest(String name) {
23
	public AssertionTest(String name) {
Lines 507-511 Link Here
507
			"The local variable error6 may not have been initialized\n" + 
507
			"The local variable error6 may not have been initialized\n" + 
508
			"----------\n");
508
			"----------\n");
509
	}
509
	}
510
	
510
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
511
	public void test018() {
512
		this.runNegativeTest(new String[] {
513
			"X.java",
514
			"public class X {\n" + 
515
			"    static final int i;\n" + 
516
			"    static {\n" + 
517
			"        assert (i = 0) == 0;\n" + 
518
			"        System.out.println(i);\n" + 
519
			"    }\n" + 
520
			"}"
521
		},
522
		"----------\n" + 
523
		"1. ERROR in X.java (at line 2)\n" + 
524
		"	static final int i;\n" + 
525
		"	                 ^\n" + 
526
		"The blank final field i may not have been initialized\n" + 
527
		"----------\n" + 
528
		"2. ERROR in X.java (at line 5)\n" + 
529
		"	System.out.println(i);\n" + 
530
		"	                   ^\n" + 
531
		"The blank final field i may not have been initialized\n" + 
532
		"----------\n");
533
	}
534
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
535
	public void test019() {
536
		this.runConformTest(new String[] {
537
			"X.java",
538
			"public class X {\n" + 
539
			"    static final int i;\n" + 
540
			"    static {\n" +
541
			"        i = 0;\n" + 
542
			"        assert i == 0;\n" + 
543
			"        System.out.println(i);\n" + 
544
			"    }\n" + 
545
			"}"
546
		},
547
		"");
548
	}
549
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
550
	public void test020() throws Exception {
551
		this.runNegativeTest(
552
			new String[] {
553
					"X.java",
554
					"public class X {\n" +
555
						"    static final int i;\n" +	
556
						"    static {\n" +	
557
							"        assert (i = 0) == 0;\n" +	
558
							"        System.out.println(i);\n" +	
559
							"    }\n" +	
560
							"}\n"	
561
			},
562
			"----------\n" + 
563
			"1. ERROR in X.java (at line 2)\n" + 
564
			"	static final int i;\n" + 
565
			"	                 ^\n" + 
566
			"The blank final field i may not have been initialized\n" + 
567
			"----------\n" + 
568
			"2. ERROR in X.java (at line 5)\n" + 
569
			"	System.out.println(i);\n" + 
570
			"	                   ^\n" + 
571
			"The blank final field i may not have been initialized\n" + 
572
			"----------\n");
573
	}
574
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
575
	public void test021() throws Exception {
576
		this.runNegativeTest(
577
			new String[] {
578
					"X.java",
579
					"public class X {\n" +
580
						"    void method1() {\n" +
581
						"		 int i;" +	
582
						"        assert (i = 0) == 0;\n" +	
583
						"        System.out.println(i);\n" +	
584
						"    }\n" +	
585
						"}\n"	
586
			},
587
			"----------\n" + 
588
			"1. ERROR in X.java (at line 4)\n" + 
589
			"	System.out.println(i);\n" + 
590
			"	                   ^\n" + 
591
			"The local variable i may not have been initialized\n" + 
592
			"----------\n");
593
	}
594
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
595
	public void test022() throws Exception {
596
		this.runNegativeTest(
597
			new String[] {
598
				"X.java",
599
				"public class X {\n" +
600
					"	public int bar() {\n" +
601
					"		return 1;\n" +
602
					"	}\n" +
603
					"    void method1() {\n" +
604
						"		 int i;" +	
605
						"        assert (i = this.bar()) == 0;\n" +	
606
						"        System.out.println(i);\n" +	
607
						"    }\n" +	
608
						"}\n"	
609
			},
610
			"----------\n" + 
611
			"1. ERROR in X.java (at line 7)\n" + 
612
			"	System.out.println(i);\n" + 
613
			"	                   ^\n" + 
614
			"The local variable i may not have been initialized\n" + 
615
			"----------\n");
616
	}
617
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361
618
	public void test023() throws Exception {
619
		this.runNegativeTest(
620
			new String[] {
621
				"X.java",
622
				"public class X {\n" +
623
					"	public int bar() {\n" +
624
					"		return 1;\n" +
625
					"	}\n" +
626
					"    void method1() {\n" +
627
						"		 int i;\n" +	
628
						"        assert i++ == 0;\n" +	
629
						"        System.out.println(i);\n" +	
630
						"    }\n" +	
631
						"}\n"	
632
			},
633
			"----------\n" + 
634
			"1. ERROR in X.java (at line 7)\n" + 
635
			"	assert i++ == 0;\n" + 
636
			"	       ^\n" + 
637
			"The local variable i may not have been initialized\n" + 
638
			"----------\n" + 
639
			"2. ERROR in X.java (at line 8)\n" + 
640
			"	System.out.println(i);\n" + 
641
			"	                   ^\n" + 
642
			"The local variable i may not have been initialized\n" + 
643
			"----------\n");
644
	}
511
}
645
}

Return to bug 328361