I'm trying to inspect Groovy generated methods on some CGLib proxied Groovy class, from Java, to learn what the return and parameter types are for methods. Ex, consider this Groovy class:
class Person {
String name
}
Groovy generates getName()
and setName()
methods for the name property. getName()
presumably returns a String
and setName()
presumably takes a String
.
But when proxying this class via CGLib and intercepting invocations against the getName
using CGLib's MethodInterceptor, method.getName()
returns getMetaClass
and method.getReturnType()
returns groovy.lang.MetaClass
.
Is there a way to learn the actual method name and return type from inside a MethodInterceptor?
Edit: Here's the call stack when intercepting an invocation of Person.getName():
ExplicitMappingInterceptor.intercept(Object, Method, Object[], MethodProxy) line: 42
GroovyMMTester$A$$EnhancerByCGLIB$$915b5b4.getMetaClass() line: not available
CallSiteArray.createPogoSite(CallSite, Object, Object[]) line: 144
CallSiteArray.createCallSite(CallSite, Object, Object[]) line: 161
CallSiteArray.defaultCall(CallSite, Object, Object[]) line: 45
AbstractCallSite.call(Object, Object[]) line: 108
AbstractCallSite.call(Object) line: 112
GroovyMMTester$Map.configure() line: 18 <-- Person.getName() call is in here, but doesn't show