commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <>
Subject Re: questions about commons-beanutils
Date Tue, 09 Mar 2010 10:56:28 GMT
On Tue, Mar 9, 2010 at 8:41 AM, Allen Yuan <> wrote:
> Hi,
> There are some questions which I cannot understand about the method
> "getAccessibleMethod(Class clazz, Method method)" in the
> "org.apache.commons.beanutils.MethodUtils".
> First,what the difference between the "method" returned and the parameter
> "method"?

The purpose of getAccessibleMethod() is to return a method that is
publicly accessible (i.e. a public method in a public class) or to
return "null" if there is no publicly accessible method. If the method
is not public it returns null. The getAccessibleMethod(Class, Method)
implementation will either return the method passed to it (if its
declared in a public class)  or if the class declaring it is not
public it will search the superclasses/interfaces for a public class
with that method declared as public. So for example you could have
something like the following:

public class Foo {
   public void dosomething() {}
private class Bar extends Foo {
   public void dosomething() {}

In this scenario whether you pass in the dosomething() method declared
in either Foo or Bar you should get the method declared in Foo

> Second,in this method if the clazz's modifier is not "public" we will search
> it's interfaces or superclass. Why?

I think I covered that above.


> I will appreciate you help very much.
> Allen.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message