| Summary: | Inherited annotations from a super class aren't returned by getAnnotation | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Eric Bartley <ebartley> |
| Component: | APT | Assignee: | Generic inbox for the JDT-APT component <jdt-apt-inbox> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | eclipse, stephan.herrmann |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
Is this the same as bug 270754? (In reply to comment #1) No, that bug is about when the processor gets invoked. This bug is about the type mirror model eclipse is exposing via java.lang.model (In reply to comment #2) > (In reply to comment #1) > > No, that bug is about when the processor gets invoked. This bug is about the > type mirror model eclipse is exposing via java.lang.model For the initial issue of that bug you're right, but looking at bug 270754 comment 6 I seem to see a connection between both issues, no? (In reply to comment #3) Ya looks like, you can close this as a dup (In reply to comment #4) > (In reply to comment #3) > > Ya looks like, you can close this as a dup Thanks for confirming. Yet, for closing we need a JDT-APT committer :) Yes, I agree this is a duplicate. *** This bug has been marked as a duplicate of bug 270754 *** |
Build Identifier: 20100917-0705 Java doc for javax.lang.model.element.Element.getAnnotation(Class<A> annotationType) says "The annotation may be either inherited or directly present on this element." I'm not seeing the behavior when my annotation processing is running in Eclipse. Reproducible: Always Steps to Reproduce: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Inherited public @interface A { } ---------- @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface B { } ---------- @A public class ClassA { } ---------- @B public class ClassB extends ClassA { } ---------- @Override public boolean process(Set<? extends TypeElement> arg0, RoundEnvironment arg1) { Set<? extends Element> elements = arg1.getElementsAnnotatedWith(B.class); for (Element e : elements) { A a = e.getAnnotation(A.class); if (a == null) { processingEnv.getMessager().printMessage(Kind.ERROR, "No inherited annotation."); } } return false; } I would expect the call to return the super classes annotation not null.