From: Jeff E. <je...@ad...> - 2002-04-24 13:46:12
|
I jython you can call a method two ways, 1. theClass.method(instance,arg),or 2. instance.method(arg) Also, jython let's you do this 3. theClass.staticMethod(args) even though there are not static methods in Python. Because of this, sometimes there are ambiguities about which method jython will call. The variable m in your jython code, the Modifier class, is an instance of java.lang.Class. Class has a non-static toString method. jython seems to prefer calling non-static methods (as in (1) above) over static methods, such as (3). So jython is calling java.lang.Class.toString and converting your argument to java.lang.Integer. Equivalent java code would be System.out.println( new Integer(Modifier.PUBLIC|Modifier.ABSTRACT).toString()); Sometimes these ambiguities in jython catch us off guard. rpcee wrote: > I'm having a bit of trouble calling this method, it seems to return the int value as a string rather than the method modifier string representation. any clues would be much appreciated. > > in java: > import java.lang.reflect.Modifier; > > public class Mods { > public static void main(String [] args) { > System.out.println(Modifier.toString(Modifier.PUBLIC | Modifier.ABSTRACT)); > } > } > > $ java Mods > public abstract > > In jython 2.1: > > $ jython > Jython 2.1 on java1.3.1 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>>>import java >>>>m=java.lang.reflect.Modifier >>>>m.toString(m.ABSTRACT | m.PUBLIC) >>>> > '1025' > > > > |