Bug 235781 - [compiler] difference to javac in definite unassignment analysis involving an exception within a constructor
Summary: [compiler] difference to javac in definite unassignment analysis involving an...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-05 05:31 EDT by Maxime Daniel CLA
Modified: 2010-01-25 14:14 EST (History)
1 user (show)

See Also:


Attachments
Proposed patch (3.82 KB, patch)
2009-12-15 23:16 EST, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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