Bug 201104 - JavaElement of a recovered type binding should not return a compilation unit with no parent
Summary: JavaElement of a recovered type binding should not return a compilation unit ...
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: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-24 12:26 EDT by Olivier Thomann CLA
Modified: 2007-09-03 09:10 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix (1.56 KB, patch)
2007-08-24 12:42 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (3.41 KB, patch)
2007-08-24 12:43 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression test (12.26 KB, patch)
2007-08-27 09:56 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2007-08-24 12:26:24 EDT
The parent of a compilation unit declaration should be a package fragment. Right now the java element of such java element has no parent. The CU is built using null as the package fragment.
Comment 1 Olivier Thomann CLA 2007-08-24 12:42:44 EDT
Created attachment 76926 [details]
Proposed fix

We use the IJavaElement of the package binding corresponding to the recovered type binding as the package fragment to build the fake compilation unit.
Comment 2 Olivier Thomann CLA 2007-08-24 12:43:17 EDT
Martin,

How does this sound?
Comment 3 Olivier Thomann CLA 2007-08-24 12:43:31 EDT
Created attachment 76927 [details]
Regression test
Comment 4 Olivier Thomann CLA 2007-08-24 13:14:29 EDT
Released for 3.4M2.

Jérôme,

Should this be a candidate for 3.3.1?
Comment 5 Olivier Thomann CLA 2007-08-24 13:14:56 EDT
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0283
Comment 6 Martin Aeschlimann CLA 2007-08-24 13:18:37 EDT
Sounds good to me! Thanks!
Comment 7 Jerome Lanneluc CLA 2007-08-27 05:00:20 EDT
+1 for 3.3.1 since clients never expect null as the parent of an ICompilationUnit. Not fixing this bug could cause NullPointerExceptions in client code. 
Comment 8 Olivier Thomann CLA 2007-08-27 09:56:02 EDT
Created attachment 77026 [details]
Proposed fix + regression test

Patch updated for 3.3.1.
Comment 9 Olivier Thomann CLA 2007-08-27 15:17:33 EDT
Reopen for 3.3.1
Comment 10 Olivier Thomann CLA 2007-08-27 15:18:47 EDT
Released for 3.3.1.
Regression test in org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0283
Comment 11 David Audel CLA 2007-09-03 09:10:36 EDT
Verified for 3.3.1 using build M20070831-2000.