Skip to content

BeanProperties.java should not be using getDeclaredFields() #63

Description

@aner-perez

BeanProperties.java uses getDeclaredFields() to iterate over properties in a bean but not all properties on a bean need to have a corresponding field on the class. This causes unwarranted CsvExceptions to be thrown claiming "Property does not exist".

A bean can have many properties which have no corresponding field on the class.

For example:

class A {
    String[] values = new String[2];
    public void setName(String name) {
        values[0] = name;
    }
    public void getName() {
        return values[0];
    }
    public void setLogin(String login) {
        values[1] = login;
    }
    public void getLogin() {
        return values[1];
    }
}

This class would have 1 field called "values" but 2 properties called "name" and "login"

Record classes generated by JOOQ are a real-world example of this pattern.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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