From: Steve Y. <st...@ca...> - 2001-07-12 05:53:00
|
Hi folks, I've been using Jython for well over a year, and it has served me faithfully without a hitch. I'm using it in an online role-playing game (http://www.cabochon.com) with thousands of active players, and I use my embedded jython interpreter(s) literally every day. I've run across an interesting problem. My game object tree has a base class (GameObject) that has a hashtable of properties, and one of the possible property values is type boolean. Usually jython figures out what I'm trying to do and converts the value '0' to Java's 'false'. I've found a case where it doesn't work: from java.lang import Boolean ... obj.setProperty("foobar", Boolean.FALSE) I also tried: obj.setProperty("foobar", 0) but that somehow turns 0 into an int value and uses that, where I really wanted a boolean. My base class has the following relevant methods: public void setIntProperty(String name, int value) public void setProperty(String name, Object value) (Notice how I've basically cloned jython's object-property list in java - I started before jython was availible. Sorry.) Presumably it's the second method that's being invoked here. So when I try to setProperty with Boolean.FALSE, jython somehow actually converts the Boolean.FALSE to a zero, and then winds up setting the property with an int value of 0 instead of a boolean value of true. Unfortunately, that dorks my code that's expecting the value to be a boolean. In case you were wondering, it means I can't uncurse certain rings in the game - funny how these issues translate into real bugs. Sooo... is there any way to force jython to invoke my method with a value that corresponds to the Java boolean value of 'false', rather than an int zero? Thanks much, -steve |