how to determine whether a method was compiled or runtime-added?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

how to determine whether a method was compiled or runtime-added?

OCsite
The reason I am playing now with metaclass is that I would need to check for a given method whether it exists (that's easy), and if it does, whether it's an originally compiled one or one added dynamically at runtime.

What's the best (most robust and reliable) way to do that? So far I haven't found any expliticly documented way. By my testing it looks like I might be able to use something like

println "$name is original: ${metaclass.pickMethod(name,args) instanceof org.codehaus.groovy.reflection.CachedMethod}"

but I am not sure whether it would work in all possible cases, and whether there's no better way?

Thanks for any insight,
OC