Bug 109118 - [1.5][compiler] Unhandled Exception Compiler error involving generics in java 1.5
Summary: [1.5][compiler] Unhandled Exception Compiler error involving generics in java...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 110806 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-09 03:01 EDT by William Kral CLA
Modified: 2006-01-10 10:31 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William Kral CLA 2005-09-09 03:01:18 EDT
If a class which uses generics has a public inner class which extends Exception
if there is ever a case where the exception needs to be caught in a different
class, even when the exception is caught in a try catch block the following two
errors show in the Problems View:

Unhandled exception type TestClass<String>.MyException	Tester.java
TestProject/com/test	line 9	September 9, 2005 2:47:41 AM
Unreachable catch block for TestClass<T>.MyException. This exception is never
thrown from the try statement body	Tester.java	TestProject/com/test	line 10
September 9, 2005 2:47:41 AM

It would appear that the eclipse compiler doesn't understands that
TestClass<String>.MyException and TestClass<T>.MyException are the same thing.

Tested with the Sun 1.5 JDK compiler and it compiles without error and runs as well.

Example Test Case is as follows:

TestClass.java:

package com.test;

public class TestClass<T> {
	
	public TestClass() throws MyException {
		throw new MyException();
	}

	public class MyException extends Exception {
		
		public MyException() {
			super();
		}
	}
}

Tester.java:

package com.test;

import com.test.TestClass.MyException;

public class Tester {

	public static void main(String[] args) {
		try {
			TestClass<String> test = new TestClass<String>();
		} catch (MyException e) {
			e.printStackTrace();
		}
	}
}
Comment 1 Philipe Mulet CLA 2005-10-07 12:03:43 EDT
Type import should perform raw conversion on leading types.
Added GenericTypeTest#test839
Comment 2 Philipe Mulet CLA 2005-10-11 04:25:57 EDT
Fixed both in 3.2 (HEAD) stream and 3.1 maintenance stream.
Comment 3 Philipe Mulet CLA 2005-10-11 04:36:46 EDT
*** Bug 110806 has been marked as a duplicate of this bug. ***
Comment 4 Frederic Fusier CLA 2006-01-09 06:48:54 EST
Reopen for 3.1.2 verification
Comment 5 Frederic Fusier CLA 2006-01-09 06:49:37 EST
We need to verify that's this bug fix is really fixed in R3_1_maintenance stream before 3.1.2 delivery...
Comment 6 Olivier Thomann CLA 2006-01-09 10:50:48 EST
Verified for 3.1.2 in M20060109-0800.
Comment 7 Olivier Thomann CLA 2006-01-10 10:31:17 EST
Verified for 3.2M4 in I20051215-1506