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


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
[EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!" 
      -- AOL CD when played backwards  (User Friendly - 200-10-15)


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

Reply via email to