Community
Participate
Working Groups
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.
Created attachment 192946 [details] Proposed fix + regression test Walter, I would take care of releasing this. Are you ok with that change ?
Created attachment 192947 [details] Proposed fix + regression test Same patch with updated copyrights.
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.
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.
Released for 3.7M7.