Skip to content

JavaMembers getFields in protected/private mode is not giving all the fields of also the Interfaces #2368

@jcompagner

Description

@jcompagner

by default JavaMembers does cl.getFields() this will give all the public fields that that class has throughout its full hierarchy including the once from the interfaces, But if we go into private or protected we call getDeclaredFields() which are just the fields of that class and we walk over the super classes
there is even a comment in that code:

// walk up superclass chain and grab fields. No need to deal specially with
// interfaces, since they can't have fields

but that is really not correct, interfaces can have fields but only static constant fields,
So if we switch for some reason to use private or protected then suddenly it will not find any of our static constant fields of our classes (those are mostly in interfaces)

I created a patch in our fork:

Servoy@1dd717f

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions