Groovy meta-programming - adding static methods to Object.metaClass
问题 I've encountered a Groovy meta-programming problem which I'm unable to solve. When adding the static method foo() to the class FooBar, then FooBar.foo() works as expected: FooBar.metaClass.static.foo = { println "hello" } FooBar.foo() However, I instead add the same static method foo() to the class Object, then FooBar.foo() fails with an MissingMethodException: Object.metaClass.static.foo = { println "hello" } FooBar.foo() // groovy.lang.MissingMethodException: // No signature of method: