From: SourceForge.net <no...@so...> - 2007-04-27 19:13:50
|
Bugs item #1708944, was opened at 2007-04-27 15:13 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1708944&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Philip Crotwell (crotwell) Assigned to: Nobody/Anonymous (nobody) Summary: overloaded setters in java not seen Initial Comment: 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. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1708944&group_id=12867 |