logo       

bug with reflection: msg#00019

lang.jython.user

Subject: bug with reflection

I was trying to get jython to do some simple reflection, but it
sometimes failes with a type error. Here is the code:

import sys
import java

if __name__ == '__main__':
arg = sys.argv[1]
c = java.lang.Class.forName(arg)
interfaces = c.getInterfaces()
for i in interfaces:
print "interface: ", i.getName()

The script takes a java class as an agument and is supposed to print
all the interfaces the class implements. It works sometimes but fails
others:

% jython bug.py java.util.HashMap
interface: java.util.Map
interface: java.lang.Cloneable
interface: java.io.Serializable

% jython bug.py java.security.Identity
interface: Traceback (innermost last):
File "bug.py", line 9, in ?
TypeError: getName(): expected 1 args; got 0

The object c is an instance of org.python.core.PyJavaClass in every
case. Any idea why this doen not work? I'm running on solaris 2.8,
with Jython 2.1 on java1.4.0 (JIT: null).

Thanks,
Curt






-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise