Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 235543

Summary: [compiler] definite unassignment analysis of try/catch unduly depends on the exception type
Product: [Eclipse Project] JDT Reporter: Maxime Daniel <maxime_daniel>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard: stalebug

Description Maxime Daniel CLA 2008-06-04 03:27:44 EDT
I20080530-1730

Eclipse rightly reports an error on the following source:
public class X {
  public static void main(String args[]) {
	final int i; // def. un.
	try {
	  if (false) {
		// def. un.
		i = 0;
		// def. as.
		throw new MyException() /* def. as. */;
		// def. un. & as.
	  }
	} catch (MyException e) {
	  /* not def. un. because not def. un. after e in every statement of the 
	   * form throw e that belongs to the try block */
	  i = 1; // error
	}
  }
}
class MyException extends Exception {
}

(comments follow the definition for definite assignment and definite unassignment of JLS 3 § 16).

While JLS 3 § 16.2.15 does not consider exception types at all in its rules for try statements, Eclipse compiles the following *without any error*:
public class X {
  public static void main(String args[]) {
	final int i; // def. un.
	try {
	  if (false) {
		// def. un.
		i = 0;
		// def. as.
		throw new MyException() /* def. as. */;
		// def. un. & as.
	  }
	} catch (Exception e) {
	  /* not def. un. because not def. un. after e in every statement of the 
	   * form throw e that belongs to the try block */
	  i = 1; // missing error!
	}
  }
}
class MyException extends Exception {
}

Note: javac never complains, which implies that it does not implement the spec in that area.
Comment 1 Maxime Daniel CLA 2008-06-04 05:59:15 EDT
Added AssignmentTest#54 (inactive) and 55.
Comment 2 Eclipse Genie CLA 2019-10-29 18:36:40 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.