| Summary: | getEnclosingType fails to return type of kind NONE for DeclaredType for static member class | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Ian Robertson <ianbrobertson> | ||||
| Component: | APT | Assignee: | Jay Arthanareeswaran <jarthana> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | eamonn, eclipse, jarthana | ||||
| Version: | 4.6 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
Yep, that looks like a bug to me too. The javadoc in Java 6 says the same thing. Will take a look. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Created attachment 265592 [details] Pair of projects which demonstrate the bug According to the javadoc for javax.lang.model.type.DeclaredType.getEnclosingType, "Only types corresponding to inner classes have an enclosing instance." Because only non-static member types are considered inner classes, an annotation processor looking at the DeclaredType representing a static member class should see a NoType of kind None when invoking getEnclosingType(). Unfortunately, the eclipse annotation processor instead returns a DeclaredType referencing the containing class of the static member type. An unfortunate side effect of this is that it makes it impossible for an annotation processor to determine if a nested type has a no-argument constructor. Calling getParameters on the ExecutableElement representing the constructor of an inner class returns a list that does not include the synthetic parameter referencing the "outer this". Only by knowing that a class is an inner class can an annotation processor conclude the existence of this parameter. This, combined with violation of the spec, is why I've chosen to give this bug an initial severity of major. I've attached a pair of maven/eclipse projects which demonstrate the bug. The first, EclipseAnnotationBug, defines an annotation, @ShowEnclosingType, and an annotation processor for @ShowEnclosingType which will emit a warning with the enclosing type and its TypeKind. The second project, EclipseAnnotationBugWitness, has a single class with two member types. The first, Inner, is a non-static member class, while the second, StaticMember, is a static member type. When running mvn compile on the EclipseAnnotationBugWitness project, the following warnings are printed: Enclosing type Witness of Witness.Inner is of type DECLARED Enclosing type none of Witness.StaticMember is of type NONE However, the same project in eclipse shows the following warnings: Enclosing type Witness of Witness.Inner is of type DECLARED Enclosing type Witness of Witness.StaticMember is of type DECLARED The second warning is evidence of the bug.