Note that there are some explanatory texts on larger screens.

plurals
  1. POInspect CGLib proxied Groovy classes from Java
    text
    copied!<p>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:</p> <pre><code>class Person { String name } </code></pre> <p>Groovy generates <code>getName()</code> and <code>setName()</code> methods for the name property. <code>getName()</code> presumably returns a <code>String</code> and <code>setName()</code> presumably takes a <code>String</code>.</p> <p>But when proxying this class via CGLib and intercepting invocations against the <code>getName</code> using CGLib's <a href="http://cglib.sourceforge.net/apidocs/net/sf/cglib/proxy/MethodInterceptor.html" rel="nofollow">MethodInterceptor</a>, <code>method.getName()</code> returns <code>getMetaClass</code> and <code>method.getReturnType()</code> returns <code>groovy.lang.MetaClass</code>.</p> <p>Is there a way to learn the actual method name and return type from inside a <a href="http://aopalliance.sourceforge.net/doc/org/aopalliance/intercept/MethodInvocation.html" rel="nofollow">MethodInterceptor</a>?</p> <p>Edit: Here's the call stack when intercepting an invocation of Person.getName():</p> <pre><code>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 &lt;-- Person.getName() call is in here, but doesn't show </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload