Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342470 - javax.lang.model.element.Element.getEnclosingElement() doesn't return null for type parameter
Summary: javax.lang.model.element.Element.getEnclosingElement() doesn't return null fo...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: APT (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 trivial (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-11 12:49 EDT by Olivier Thomann CLA
Modified: 2011-04-11 16:52 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix + regression test (2.29 KB, patch)
2011-04-11 12:51 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression test (3.63 KB, patch)
2011-04-11 12:53 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression test (3.83 KB, patch)
2011-04-11 12:58 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 2011-04-11 12:49:36 EDT
The method javadoc has been changed between 1.6 and 1.7 to no longer return null for type parameter.
See http://download.java.net/jdk7/docs/api/javax/lang/model/element/Element.html#getEnclosingElement()

vs:

http://download.oracle.com/javase/6/docs/api/javax/lang/model/element/Element.html#getEnclosingElement()

Checking with javac 1.6, it looks like the System compiler never returned null. So we should also fix our implementation to make sure we match the new documentation.
I don't think we should fix it according to the target source version of the annotation processor. We should simply return the getGenericElement() value in this case.
Comment 1 Olivier Thomann CLA 2011-04-11 12:51:33 EDT
Created attachment 192946 [details]
Proposed fix + regression test

Walter, I would take care of releasing this.
Are you ok with that change ?
Comment 2 Olivier Thomann CLA 2011-04-11 12:53:29 EDT
Created attachment 192947 [details]
Proposed fix + regression test

Same patch with updated copyrights.
Comment 3 Olivier Thomann CLA 2011-04-11 12:58:36 EDT
Created attachment 192948 [details]
Proposed fix + regression test

Improved regression test to check that the getEnclosingElement() is equals to the getGenericElement() for type parameter instead of just checking it is not null.
Comment 4 Walter Harley CLA 2011-04-11 13:21:25 EDT
Sounds like a typical case of Sun changing the spec to match their implementation, rather than changing the implementation to match the spec.

I checked the Sun bug database but I don't see any commentary on this.  I think it is okay to change the behavior for 3.7 given that javac 1.6 works this way.
Comment 5 Olivier Thomann CLA 2011-04-11 16:52:13 EDT
Released for 3.7M7.