Bug 198051 - [1.5][compiler] Improper Polymorphic Exception Handling
Summary: [1.5][compiler] Improper Polymorphic Exception Handling
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3.1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-26 20:16 EDT by Eric Inman CLA
Modified: 2007-09-17 11:19 EDT (History)
3 users (show)

See Also:


Attachments
Proposed patch (2.87 KB, patch)
2007-08-14 14:52 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Inman CLA 2007-07-26 20:16:13 EDT
Build ID: I20070625-1500

Steps To Reproduce:
See classes A and B below, which are from separate compilation units. The constructor for A has a type parameter T which extends Throwable and is thrown by the constructor. Method a() calls the constructor with actual type parameter ClassNotFoundException, and a() throws ClassNotFoundException, thus adequately handling the exception thrown by the contructor.

However, when method b() in class B tries to do the same thing, the compilation error "Unhandled exception type Throwable" occurs at the constructor call.

If class B is placed in the same compilation unit as A, then the problem goes away.

More information:
public final class A {
	
	<T extends Throwable> A() throws T {}
	
	void a() throws ClassNotFoundException {
		new <ClassNotFoundException> A();}
}

public final class B {
	
	void b() throws ClassNotFoundException {
		new <ClassNotFoundException> A();}
}
Comment 1 Olivier Thomann CLA 2007-07-26 21:21:59 EDT
Reproduced with HEAD.
Steps to reproduce:
1) Create A.java with the contents:
public final class A {

        <T extends Throwable> A() throws T {}

        void a() throws ClassNotFoundException {
                new <ClassNotFoundException> A();}
}
2) Create B.java with the contents:

public final class B {

        void b() throws ClassNotFoundException {
                new <ClassNotFoundException> A();}
}

3) Compile both classes at the same time. The compilation succeeds.
4) Make a change in B.java and recompile.
5) An error is reported on the constructor invocation.
Unhandled exception type Throwable
Comment 2 Eric Inman CLA 2007-07-26 22:11:22 EDT
(In reply to comment #1)
...
> 3) Compile both classes at the same time. The compilation succeeds.
...

If I do a clean on the project containing only the test case, then the compilation succeeds. In the project where the problem originally was noticed, however, doing a clean on that project or on all projects does not cause the compilation to succeed.

Comment 3 Kent Johnson CLA 2007-08-09 14:29:22 EDT
Eric - how many source files are in your original project ?

We divide up large projects (> 2000 source files) into bundles so we don't use too much memory trying to compile 1000's of source files at once.
Comment 4 Eric Inman CLA 2007-08-09 14:57:28 EDT
(In reply to comment #3)
> Eric - how many source files are in your original project ?
> 
> We divide up large projects (> 2000 source files) into bundles so we don't use
> too much memory trying to compile 1000's of source files at once.
> 

I don't think any of my projects are that large. The total in all of the projects that are affected by a single compile might be that large, however. A single compile can compile files in multiple projects. Are you talking about something other than using multiple Java projects?
Comment 5 Kent Johnson CLA 2007-08-09 15:02:02 EDT
We build each project by itself and propagate the changes to its dependents.

How large is the project that has this problem?
Comment 6 Eric Inman CLA 2007-08-09 15:38:47 EDT
(In reply to comment #5)
> We build each project by itself and propagate the changes to its dependents.
> 
> How large is the project that has this problem?
> 

The project containing the constructor has 100+ source files. The project calling that constructor has 60+ source files. All the projects together contain 2100+ source files. The project containing the constructor is heavily referenced by a good share of the other projects.

My work-around has been to create in the class with the constructor a static method with the same type parameters and value parameters and have it call the constructor, and then everyone else calls the static method. That has been working just fine. 
Comment 7 Kent Johnson CLA 2007-08-14 14:52:23 EDT
Created attachment 76076 [details]
Proposed patch

Incorrectly decoded the generic signature of a constructor.

Straight forward fix.
Comment 8 Kent Johnson CLA 2007-08-14 14:56:29 EDT
Fixed and released into HEAD for 3.4M2

Added GenericTypeTest 1149
Comment 9 Eric Inman CLA 2007-08-14 16:32:16 EDT
(In reply to comment #8)
> Fixed and released into HEAD for 3.4M2
> 
> Added GenericTypeTest 1149
> 

Thanks for getting this figured out and fixed!
Comment 10 Kent Johnson CLA 2007-08-15 10:44:35 EDT
Eric - please try your case with one of the nightly builds or next week's integration build to double check that it fixes your problem.

thanks
Comment 11 Kent Johnson CLA 2007-08-24 10:26:16 EDT
Released into 3.3.1 stream
Comment 12 Philipe Mulet CLA 2007-08-29 06:19:00 EDT
+1 for 3.3.1
Comment 13 Maxime Daniel CLA 2007-09-03 08:09:45 EDT
Verified for 3.3.1 using build M20070831-2000.
Comment 14 Eric Inman CLA 2007-09-09 17:35:14 EDT
(In reply to comment #10)
> Eric - please try your case with one of the nightly builds or next week's
> integration build to double check that it fixes your problem.
> thanks

Sorry for the delayed response.

Does work for M20070905-1045.

Does not work for 3.3 or 3.4M1.

I believe this is what you expected. Thanks for the fix!
Comment 15 Jerome Lanneluc CLA 2007-09-17 11:19:28 EDT
Verified for 3.4M2 using I20070917-0010