title: Java annotation processor ignores annotation in parent class
body: <p>I've got the classes below. Two annotations (<strong>AnnotA</strong> and <strong>AnnotB</strong>), a class '<strong>Child</strong>.java' (with @AnnotA) and its' parent '<strong>Base</strong>.java'  (with @AnnotB). </p>
  
  <p>When compiling Child.java, my annotation processor repors <strong>AnnotA</strong> but it doesn't report the annotations (<strong>AnnotB</strong>) found in Base.java. </p>
  
  <p>AnnotA.java</p>
  
  <pre><code>import java.lang.annotation.*;
  @Retention(RetentionPolicy.RUNTIME)
  @Target({ ElementType.TYPE })
  public @interface AnnotA
      {
      }
  </code></pre>
  
  <p>AnnotB.java</p>
  
  <pre><code>import java.lang.annotation.*;
  @Retention(RetentionPolicy.RUNTIME)
  @Target({ ElementType.TYPE })
  public @interface AnnotB
      {
      }
  </code></pre>
  
  <p>Base.java</p>
  
  <pre><code>@AnnotB
  public class Base
      {
      }
  </code></pre>
  
  <p>Child.java</p>
  
  <pre><code>@AnnotA
  public class Child extends Base
      {
      }
  </code></pre>
  
  <p>MyProc.java</p>
  
  <pre><code>import javax.annotation.processing.*;
  import java.lang.annotation.*;
  import javax.lang.model.*;
  import javax.lang.model.element.*;
  import javax.tools.*;
  import java.util.*;
  import java.util.stream.*;
  
  @SupportedSourceVersion(SourceVersion.RELEASE_8)
  public class MyProc  extends AbstractProcessor
      {
      @Override
      public Set&lt;String&gt; getSupportedAnnotationTypes()  {
          final Set&lt;String&gt; set = new HashSet&lt;&gt;();
          set.add("AnnotA");
          set.add("AnnotB");
          return set;
          }
      @Override
      public boolean process(final Set&lt;? extends TypeElement&gt; annotations,
          final RoundEnvironment roundEnv
          ) {
          roundEnv.getElementsAnnotatedWith(AnnotA.class).stream().
              forEach(E-&gt;{System.err.println("AnnotA&gt;&gt;" + E + " "+ E.getAnnotation(AnnotA.class));});
  
          roundEnv.getElementsAnnotatedWith(AnnotB.class).stream().
              forEach(E-&gt;{System.err.println("AnnotB&gt;&gt;" + E + " "+ E.getAnnotation(AnnotB.class));});
          return true;
          }
      }
  </code></pre>
  
  <p>Here is the compilation process and it's output, as your can see, there is no message about AnnotB while Parent.java is a parent of Child.java</p>
  
  <pre><code>rm -rf tmp
  mkdir -p tmp/META-INF/services
  javac -d tmp MyProc.java
  echo "MyProc" &gt; tmp/META-INF/services/javax.annotation.processing.Processor
  jar cvf myproc.jar -C tmp .
  added manifest
  ignoring entry META-INF/
  adding: META-INF/services/(in = 0) (out= 0)(stored 0%)
  adding: META-INF/services/javax.annotation.processing.Processor(in = 7) (out= 9)(deflated -28%)
  adding: AnnotB.class(in = 363) (out= 221)(deflated 39%)
  adding: MyProc.class(in = 2512) (out= 1118)(deflated 55%)
  adding: AnnotA.class(in = 363) (out= 221)(deflated 39%)
  ##
  mkdir -p tmp
  javac -processorpath myproc.jar -d tmp Child.java
  AnnotA&gt;&gt;Child @AnnotA()
  warning: Implicitly compiled files were not subject to annotation processing.
    Use -implicit to specify a policy for implicit compilation.
  1 warning
  rm -rf tmp
  </code></pre>
  
  <p>what's wrong with this code ? 
  Thanks .</p>