Hi,

consider the following beans:

--- cut ---
package beans;

abstract class AbstractBean {
  private String foo = null;

  public AbstractBean() {}

  public String getFoo() { return this.foo; };

  public void setFoo(String foo) { this.foo = foo; };
}
--- cut ---

--- cut ---
package beans;

public class PublicBean
  extends AbstractBean {
  private String bar = null;

  public PublicBeanBean() { super(); }

  public String getBar() { return this.bar; };

  public void setBar(String bar) { this.bar = bar; };
}
--- cut ---

import beans.PublicBean;
[...]
PublicBean bean = new PublicBean();
BeanUtils.setSimpleProperty(bean,  "foo", "value");

fails. The reason for this is the Property visibility check in the
MethodUtils::getAccessibleMethod, which considers the "setFoo/getFoo"
Property setters to be inaccessible because they're not defined in a
public class and not defined by any Interface implemented by the Bean.

My question now is: Is this correct? The public visibility of the
PublicBean class makes IMHO the public methods AbstractBean::setFoo()
and AbstractBean::getFoo() accessible, even if the declaring class
(AbstractBean) is not public.

This is not an academic question, it is exactly the problem I've
written about yesterday with commons-dbcp. There is "public
SharedPoolDataSource" which extends "abstract
InstanceKeyDataSource". One cannot set properties defined in
InstanceKeyDataSource with PropertyUtils because of this problem.

I'd be interested if the correct solution is to add a "public" to
InstanceKeyDataSource or rewrite the MethodUtils::getAccessibleMethod().

        Regards
                Henning

-- 

"In einem Abwägungsprozess, wollen wir weiter regieren, hat sich die
SPD und die Bundesregierung und auch der Bundesfinanzminister fürs
Weiterregieren entschieden und gegen die Ehrlichkeit" -- Oswald
Metzger, Bündnis '90/Die Grünen, 12.11.2002

-- 
Henning Schmiedehausen     "We're Germans and we use Unix. 
[EMAIL PROTECTED]            That's a combination of two demographic groups
[EMAIL PROTECTED]    known to have no sense of humour whatsoever."
                               -- Hanno Mueller in de.comp.os.unix.programming 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to