Bug 235781

Summary: [compiler] difference to javac in definite unassignment analysis involving an exception within a constructor
Product: [Eclipse Project] JDT Reporter: Maxime Daniel <maxime_daniel>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.4   
Target Milestone: 3.6 M5   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Maxime Daniel CLA 2008-06-05 05:31:41 EDT
I20080604-2000

On the following test case, Eclipse complains that i may remain uninitialized, while javac is silent:
public class X {
  final int i;
  X() {
	if (true) {
	  throw new NullPointerException();
	}
  }
}

Note that both keep quiet on the following:

public class X {
  X() {
	final int i;
	if (true) {
	  throw new NullPointerException();
	}
	System.out.println(i);
  }
}

Added FlowAnalysisTest#50 & 51.
Comment 1 Srikanth Sankaran CLA 2009-12-15 07:49:23 EST
class Y {
	Y(Object o) {
	}
}
public class X extends Y {
	final int blank;
 {
    if (true)
        throw new NullPointerException();
 }
 X() {
    super(new Object() {});     
 }
}

elicits an error from us, but not from javac (5/6/7)

This behavior is codified by us in org.eclipse.jdt.core.tests.compiler.regression.FlowAnalysisTest.test031()
Comment 2 Srikanth Sankaran CLA 2009-12-15 23:16:46 EST
Created attachment 154536 [details]
Proposed patch

Proposed fix and tests
Comment 3 Srikanth Sankaran CLA 2009-12-16 02:15:54 EST
Released in HEAD for 3.6M5
Comment 4 Olivier Thomann CLA 2010-01-25 14:14:33 EST
Verified for 3.6M5 using I20100125-0800