From: Martin <m.m...@gm...> - 2002-01-18 17:27:20
|
hi, i pass a java-object to very simple python-script. The scripts manipulate this object. Now i had to extend this java-object, and i handle this objects in other python scripts, but further passing the object as the superclass. In the extended Class i added 2 Methodes and overloaded another one. Now i get TypeError: - args; got 5 update(): expected 1 or 4 update() is the overload method, wich have now 5 parameter. The strange thing is the other two methods are called correct. def do_stuff(): global java_object # getSpecialValue1() &2 are declared in the subclass of java_object, that works ! value1=java_object.specialValue1 value2=java_object.specialValue2 value3=java_object.value1 #update(double,double,double,double,double) is overloaded from Java_Object # that fails java_object.update(value1,value2,value3,value2+value1,value2-value3) Just a sketch of the classes and methods: class Java_Object{ public double getValue1(){return -1;} public double getValue2(){return -1;} public void (Object o) public void update(double a, double b, double c, double d){//do stuff} } class Java_Object2 extends Java_Object{ //new method public double getSpecialValue1(){return -1;} //new method public double getSpecialValue1(){return -1;} // 5 parameter instead 4 public void update(double a, double b, double c, double d, double z){//do stuff} } //main point für script processing public void invokeScript(String function, Java_Object java_object){ pythonInterpreter.set("java_object",java_object) pythonInterpreter.exec(function) } I've read that jython get confused with different method signatures, but only examples how to call methods of the super class, i want to call a method of a subclass. In java i would cast java_object to Java_Object2, but python have no concept of casting(AFAIK). So what can i do? any help, or pointers to documention & examples are very appreciated. -- Martin Möbius |