From: Chermside, M. <mch...@in...> - 2004-04-26 12:27:36
|
I am trying to write some jython code for printing out descriptions of java objects (using reflection). One of the tasks I need to perform is, given a java.lang.reflect.Method object, to obtain a description of it's modifiers (public final static, etc). Fortunately, there's a handy function for doing this: java.lang.reflect.Modifier.toString(int) It takes an int (primitive), and returns a String. The int can be obtained from java.lang.reflect.Method.getModifiers(), but for this example I'll simply use 2 (which is the code for "private"). Here's a sample jython program: Jython 2.1 on java1.3.1_11 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import java.lang.reflect.Modifier as Modifier >>> Modifier.toString(2) # should return 'private' '2' >>> I expected it to return 'private' but it returned '2' instead. I've got two questions: (1) Why? (2) How do I fix it? -- Michael Chermside PS: Please CC me <mch...@in...> with any responses as I am not currently on the mailing list. This email may contain confidential or privileged information. If you belie= ve you have received the message in error, please notify the sender and del= ete the message without copying or disclosing it. |