Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1710

ReflectionToStringBuilder changes in version 3.13.0 has broken the logic for overriding classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.14.0
    • None
    • None

    Description

      It is said that overriding classes should overload two methods:  #getValue(java.lang.reflect.Field)} and #accept(java.lang.reflect.Field)}.

      But since 3.13.0 getValue(java.lang.reflect.Field)} no longer called in 
      appendFieldsIn.

      • System.out.println("An object: " + ReflectionToStringBuilder.toString(anObject));
      •  
      • A subclass can control field output by overriding the methods:
      •  
      • <li>{@link #accept(java.lang.reflect.Field)}</li>
      • <li>{@link #getValue(java.lang.reflect.Field)}</li>

      Also consider to use trySetAccessible instead of 
      AccessibleObject.setAccessible(fields, true); and skip not accessible fields.

      Attachments

        Activity

          People

            Unassigned Unassigned
            oksiblack Oksana
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: