At 23:16 11.06.2002 -0700, you wrote:
> > >I have written code myself that when the basic bean
> > >introspection fails (because there is no matching getter/setter) it falls
> > >back to searching and calling the desired version of the method directly.
> >
> > That's an interesting approach. I had not thought of it.
>
>I was looking at the config.PropertySetter.java code. It should not be hard
>to add this functionality. Should I?
I don't think so. Consider the following program:
import java.beans.*;
import java.lang.reflect.*;
public class Test {
public static void main(String args[]) throws Exception {
PropertyDescriptor[] props = introspect(X.class);
for(int i = 0; i < props.length; i++) {
System.out.println("Name: "+props[i].getName()
+", read: "+ props[i].getReadMethod()
+", write: "+ props[i].getWriteMethod());
}
}
static PropertyDescriptor[] introspect(Class clazz) throws Exception {
BeanInfo bi = Introspector.getBeanInfo(clazz);
return bi.getPropertyDescriptors();
}
}
class X {
public void setYoo(int i) {}
public void setYoo(String s) {}
}
If you compile and run Test, you get:
> javac Test.java
> java Test
Name: yoo, read: null, write: public void X.setYoo(int)
Name: class, read: public final native java.lang.Class
java.lang.Object.getClass(), write: null
Now, if you change the order of declaration of setYoo(int) and
setYoo(String), as in:
class X {
public void setYoo(String s) {}
public void setYoo(int i) {}
}
> javac Test
> java Test
Name: yoo, read: null, write: public void X.setYoo(java.lang.String)
Name: class, read: public final native java.lang.Class
java.lang.Object.getClass(), write: null
Oops, setYoo(int) is gone. Scarry no? (This is on JDK 1.3.1.)
I think it is best to simply shy away from homonym setter methods. We
should not try to compensate for this JavaBeans introspection behavior. You
might have a different analysis of the situation. So I'm all ears.
>-Mark
--
Ceki
SUICIDE BOMBING - A CRIME AGAINST HUMANITY
Sign the petition: http://www.petitiononline.com/1234567b
I am signatory number 22106. What is your number?
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>