Message1573
public class StringBean {
String[] pod;
public String[] getPod() {
return pod;
}
public void setPod(String[] pod) {
this.pod = pod;
}
public void setPod(String pod) {
this.pod = new String[] {pod};
}
}
with the above class, this code fails in jython:
s = StringBean()
s.names='polebean'
with a can't convert String to String[] error:
TypeError: can't convert 'polebean' to [Ljava.lang.String;
Seems that jython should look for other "setters" that match the type of the RHS even if they take an argument of a different type from the getters return value.
Looking at the code, I think the problem steems from the fact that PyBeanProperty holds a single setter Method.
In PyType.fillInClassic(), the only methods that are searched for to put in the PyBeanProperty are ones with the correct name, ie setXYZ and with a single argument that is of the same type as the return of the getter. Any methods named correctly, setXYZ but with a different type in the argument are ignored.
In addition, if there is no getter, then the last setter to be found determines the bean params type. Probably would be better to not have a type if there are multiple setters but not a getter to specify it. Why would the last setter found be more important than the first one?
In some sense overloading setters isn't part of the real "javabean spec" but it seems a reasonible thing for java classes to do and would be nice if jython handled it.
|
|
| Date |
User |
Action |
Args |
| 2008-02-20 17:17:48 | admin | link | issue1708944 messages |
| 2008-02-20 17:17:48 | admin | create | |
|