From: James H. <jh...@pa...> - 2001-06-18 20:27:09
|
Thank you for the clear explanation... I'll look forward to the new version! James At 6/18/2001 06:22 PM +0000, Finn Bock wrote: >On Fri, 15 Jun 2001 16:28:33 -0600, you wrote: > > >Hi, > > > >So far I think Jython is pretty cool... but I've got a problem/question... > > > >First off, here's my sample code: > > > >... > > > >My problem is that I really need the method > > > > void setAttribute(String key, Object attr) > > > >to be this: > > > > void setAttribute(String key, Serializable attr) > >Jython-2.0 did not handle Serializable argument very well. This have >been fixed in jython-2.1a1 where your example works. > > >Can someone explain this to me? > >When the python code > > theMap.setAttribute("crapKey", "crapVal") > >is executed jython is faced with a choice. Should it insert the the >PyString instance that wraps "crapVal" or should it unwrap the string >and insert the java.lang.String instance. If the method signature uses >Object, jython always unwraps, which is why that works in you example. >If the method signature used Serializable, Jython-2.0 would check and >see that PyString implement Serializable (it does) and pass over the >PyString wrapper. In Jython-2.1a1, a Serializable signature will cause >unwrapping of string, ints, longs, floats, classes and instances. > >regards, >finn |