In Python, I see which methods and fields objects have:
print dir(my_object)
What is equivalent to what in Groovy (provided that it is)?
It looks especially nice in Groovy (untested, taken from this link , so the credit code should go there):
// Introspection, know all the details about classes : // List all constructors of a class String.constructors.each{println it} // List all interfaces implemented by a class String.interfaces.each{println it} // List all methods offered by a class String.methods.each{println it} // Just list the methods names String.methods.name // Get the fields of an object (with their values) d = new Date() d.properties.each{println it}
The general term you are looking for is introspection .
As described here , to find all the methods defined for a String object:
"foo".metaClass.methods*.name.sort().unique()
It is not as simple as the Python version, maybe someone else can show a better way.
Besides using the regular Java reflection API, there are:
http://docs.codehaus.org/display/GROOVY/JN3535-Reflection
You can also play games with metaclasses.