commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: org.apache.commons.beanutils.PropertyUtils.describe(Object )
Date Wed, 27 Jul 2005 01:36:48 GMT
On Tue, 2005-07-26 at 23:54 +0800, Tamas Szabo wrote:
> Hi,
> I had some code which gets the properties of a bean and puts them in a Map.
> Now I switched to Commons Beanutils, and I'm using 
> org.apache.commons.beanutils.PropertyUtils.describe(Object )
> to do the same, but I learned that the Object.getClass() is considered a 
> getter, so I get a class property in the Map.
> In my own code I explicitly checked that the properties are not comming 
> from java.lang.Object.
> When I write a Bean I declare all the properties explicitly for it, but 
> because every object extends java.lang.Object
>  ==> I will have a class property in all of my beans.
> Is this the normal behaviour?
> Should Object.getClass() be considered a getter and class a property of 
> every JavaBean?

Yes, this is normal behaviour.

Try writing a simple test using the standard java.beans.Introspector
class and you will see that "class" is reported as a property of every

For a class SomeClass, try this:

    BeanInfo bi = Introspector.getBeanInfo(SomeBean.class);
    PropertyDescriptor[] props = bi.getPropertyDescriptors();
    for(PropertyDescriptor pd : props) {
      System.out.println("name: " + pd.getName());
      System.out.println("read: " + pd.getReadMethod());
      System.out.println("write: " + pd.getWriteMethod());



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

View raw message