You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Allen Yuan <al...@gmail.com> on 2010/03/09 09:41:25 UTC

questions about commons-beanutils

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"?
Second,in this method if the clazz's modifier is not "public" we will search
it's interfaces or superclass. Why?
I will appreciate you help very much.

Allen.

Re: questions about commons-beanutils

Posted by Niall Pemberton <ni...@gmail.com>.
On Tue, Mar 9, 2010 at 8:41 AM, Allen Yuan <al...@gmail.com> 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
returned.

> 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.

Niall

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org