Intercept all method calls for all metaclasses in groovy
问题 I am trying to intercept all method calls inside Groovy scripts running in a Java environment. Specially I want to check the return type of all method calls, and if it is X I want to replace it with Y . I know you can intercept using invokeMethod on the MetaClass, but I can only do that to the script class that I compile. If the script in turn calls a method on class A then it will create a new MetaClass[A] that I can't intercept without earlier having manually fetched that MetaClass from the