I'm trying to write an object inspector for Java objects in Jython, and I want to determine how many arguments a given Java method expects. Is there any way to do that in python, or do I have to use Java reflection for that.
To explain, I'd like to call all "get..." methods of a Java object that don't take any arguments:
from java.util import Date, ArrayList
def numberOfArguments(fct):
# Some magic happens here
return 0
def check(o):
print("")
print(type(o).name)
for fctName in dir(o):
if not str(fctName).startswith("get"): continue
print("== " + fctName)
fct = eval("o."+fctName)
if numberOfArguments(fct) == 0:
print(" " + str(fct()))
check(Date())
check(ArrayList())