getAllMembers from Elements does not return Parent's member annotations

116 views Asked by At

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?

1

There are 1 answers

0
user5258532 On

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