0

getAllMembers from java.lang.Model.Util.Elements does not return Parent's member annotations

Example:

public class Foo {

@QueryParam("firstname")
private String name;

public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}}



public class Bar extends Foo{

@QueryParam("address")
private String address;

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}}      

From AnnotationProcessor when I try to read the members of TypeElement Bar, by using Elements getAllMembers(Bar as TypeElement) it gives me right members, however, I can't read annotations of the Parent class i.e. In this case, annotations "QueryParam" of Foo class member "name" which is the parent of Bar.

Any idea what am I missing here?

Jud
  • 1,324
  • 3
  • 24
  • 47
Kunal
  • 2,929
  • 6
  • 21
  • 23

1 Answers1

0

Your superclass field is private - getAllMembers returns all inherited/declared members. So bar does not inherit the field 'name' or its anntoation.