#63 Is-Accessible problem w/ abstract super classes

closed
None
5
2007-02-09
2006-11-20
No

Hi,
when specifying is-accessible = true for fields without setters, we are finding that these fields are not being mapped if they are declared in a superclass and not in subclasses.

We traced this to a problem/feature in the FieldPropertyDescriptor constructor:
field = bean.getDeclaredField(fieldName);

My colleague, Luke Robinson, added a method to the same FieldPropertyDescriptor which recursively finds the field from the superclass if it is not in the child class:

private Field getFieldFromBean(Class clazz, String fieldName) throws NoSuchFieldException {
try {
return clazz.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
if (clazz.getSuperclass() != null) {
return getFieldFromBean(clazz.getSuperclass(), fieldName);
}
throw e;
}
}

and changed the constructor line above to call this method, and this fixed our problem. All your unit tests passed as well.

I can provide this as a patch?
Regards
Alan

Discussion

  • Matt Tierney

    Matt Tierney - 2006-11-20

    Logged In: YES
    user_id=1236069
    Originator: YES

    Thanks to Alan for submitting a patch. I will apply to the 2.5 code base

     
  • Matt Tierney

    Matt Tierney - 2006-12-09

    Logged In: YES
    user_id=1236069
    Originator: YES

    Thanks Alan and Luke for submitting this patch. I applied it to the 2.5 code base w/o any problems. Do you happen to have a simple unit test that I could also add to the code base? Thanks again

     
  • Matt Tierney

    Matt Tierney - 2006-12-09
    • status: open --> pending
     
  • SourceForge Robot

    • status: pending --> closed
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 45 days (the time period specified by
    the administrator of this Tracker).

     
  • Matt Tierney

    Matt Tierney - 2007-01-24
    • status: closed --> pending
     
  • Matt Tierney

    Matt Tierney - 2007-01-24

    Logged In: YES
    user_id=1236069
    Originator: YES

    reassign to pending status

     
  • Matt Tierney

    Matt Tierney - 2007-02-09
    • status: pending --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks