Introspector (bug)?

Hi

I notice a behavior in the Introspector.getPropertyDescriptors() that i qualify has a bug.

The problem occurs when i create a bean that as a property with a letter in lowercase followed by one in uppercase and what ever you want next. Something like xBlalala.

When using the Introspector to get the properties from the bean, it will return a property name of XBlalala for that property, and not the correct name.

I've set up an example.

My bean:

publicclass SampleBean{

private String xBigError;

private String ok;

public SampleBean(){

}

public String getXBigError(){

return xBigError;

}

publicvoid setXBigError(String bigError){

xBigError = bigError;

}

public String getOk(){

return ok;

}

publicvoid setOk(String ok){

this.ok = ok;

}

}

My Test Class:

import java.beans.BeanInfo;

import java.beans.IntrospectionException;

import java.beans.Introspector;

import java.beans.PropertyDescriptor;

publicclass Main{

publicstaticvoid main(String[] args){

SampleBean bean =new SampleBean();

try{

BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());

PropertyDescriptor descriptors[] = beanInfo.getPropertyDescriptors();

int i=0;

PropertyDescriptor descriptor =null;

while(i<descriptors.length){

descriptor = descriptors[i++];

System.out.println("Name = "+descriptor.getName());

}

}catch (IntrospectionException e){

e.printStackTrace();

}

}

}

This will produce the following output:

Name = XBigError

Name =class

Name = ok

As you can see, property xBigError is being printed with thex in uppercase, witch is not the case in the bean property.

So, what is the problem here? Is this a bug?

Note:

I'm using JVM 1.5.0">

[3531 byte] By [kimilea] at [2007-11-27 6:55:21]
# 1
> Is this a bug?You could call it that. Or you could call it a design error. My experience with the feature was with a property named "eMailAddress". At any rate you can't do that and you'll have to change the name of the property. I changed mine to "emailAddress".
DrClapa at 2007-7-12 18:30:46 > top of Java-index,Core,Core APIs...
# 2
I've already changed my property name... it's a little bit annoying though!Thankskimile
kimilea at 2007-7-12 18:30:46 > top of Java-index,Core,Core APIs...
# 3
> I've already changed my property name... it's a little bit annoying though!Yeah. There are some frustrated comments in the Hibernate documentation regarding this feature, basically saying "Don't blame us for this".
DrClapa at 2007-7-12 18:30:46 > top of Java-index,Core,Core APIs...