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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/flow/NullInfoRegistry.java (-1 / +8 lines)
Lines 319-325 Link Here
319
			// prot. non null
319
			// prot. non null
320
		& ((a2 = this.nullBit2) | (a4 = this.nullBit4));
320
		& ((a2 = this.nullBit2) | (a4 = this.nullBit4));
321
			// null or unknown
321
			// null or unknown
322
	m2 = s1 & (s2 = this.nullBit2) & (s3 ^ s4)
322
	m2 = s1 & (s2 = this.nullBit2) & (s3 ^ s4) // TODO(stephan): potential typo: should this be "s2 = source.nullBit2"???
323
			// prot. null
323
			// prot. null
324
		& ((a3 = this.nullBit3) | a4);
324
		& ((a3 = this.nullBit3) | a4);
325
			// non null or unknown
325
			// non null or unknown
Lines 330-341 Link Here
330
				| (ns2 = ~s2) & s3 & ns4 & (a2 | a4)
330
				| (ns2 = ~s2) & s3 & ns4 & (a2 | a4)
331
				| ns2 & ns3 & s4 & (a2 | a3));
331
				| ns2 & ns3 & s4 & (a2 | a3));
332
	if ((m = (m1 | m2 | m3)) != 0) {
332
	if ((m = (m1 | m2 | m3)) != 0) {
333
		long x = ~this.nullBit1 & a2 & a3 & a4; 
333
		newCopy = true;
334
		newCopy = true;
334
		source = source.unconditionalCopy();
335
		source = source.unconditionalCopy();
335
		source.nullBit1 &= ~m;
336
		source.nullBit1 &= ~m;
336
		source.nullBit2 &= (nm1 = ~m1) & ((nm2 = ~m2) | a4);
337
		source.nullBit2 &= (nm1 = ~m1) & ((nm2 = ~m2) | a4);
337
		source.nullBit3 &= (nm1 | a2) & nm2;
338
		source.nullBit3 &= (nm1 | a2) & nm2;
338
		source.nullBit4 &= nm1 & nm2;
339
		source.nullBit4 &= nm1 & nm2;
340
		if (x != 0) {
341
			source.nullBit1 &= ~x;
342
			source.nullBit2 |= x;
343
			source.nullBit3 |= x;
344
			source.nullBit4 |= x;
345
		}
339
	}
346
	}
340
	if (this.extra != null && source.extra != null) {
347
	if (this.extra != null && source.extra != null) {
341
		int length = this.extra[2].length, sourceLength = source.extra[0].length;
348
		int length = this.extra[2].length, sourceLength = source.extra[0].length;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (+29 lines)
Lines 5484-5489 Link Here
5484
			"");
5484
			"");
5485
}
5485
}
5486
5486
5487
//null analysis -- try/finally
5488
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=320170 -  [compiler] [null] Whitebox issues in null analysis
5489
//trigger nullbits 0111 (pot n|nn|un), don't let "definitely unknown" override previous information
5490
public void test0536_try_finally() {
5491
	this.runNegativeTest(
5492
		new String[] {
5493
			"X.java",
5494
			"public class X {\n" +
5495
			" X bar () { return null; }\n" +
5496
			" void foo() {\n" +
5497
			"   X x = new X();\n" +
5498
			"   try {\n" +
5499
			"     x = null;\n" +
5500
			"     x = new X();\n" +  // if this throws an exception finally finds x==null
5501
			"     x = bar();\n" +
5502
			"   } finally {\n" +
5503
			"     x.toString();\n" + // complain
5504
			"   }\n" +
5505
			" }\n" +
5506
			"}\n"},
5507
		"----------\n" + 
5508
		"1. ERROR in X.java (at line 10)\n" + 
5509
		"	x.toString();\n" + 
5510
		"	^\n" + 
5511
		"Potential null pointer access: The variable x may be null at this location\n" + 
5512
		"----------\n",
5513
	    JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
5514
}
5515
5487
// null analysis -- try/catch
5516
// null analysis -- try/catch
5488
public void test0550_try_catch() {
5517
public void test0550_try_catch() {
5489
	this.runConformTest(
5518
	this.runConformTest(

Return to bug 320170