<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    JBREFLECT-5 - Implementing generics in JavassistClassInfo
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/kabir.khan%40jboss.com">Kabir Khan</a> in <i>JBoss Microcontainer Development</i> - <a href="http://community.jboss.org/message/539766#539766">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>2 - classloader for parameterized type</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I posted this last night right after my "1 - other problem", but could not see it again today?!?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Anyway, for a test still using SomeSignature and SomeValue, but now uses the lazy feature where I do something along the lines of</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> testClasses() <font color="navy"><b>throws</b></font> Throwable
<font color="navy">{</font>
&#160;&#160; generateClasses();
&#160;&#160; ClassInfo info = (Classinfo)getTypeInfoFactory().getTypeInfo(SomeSignature.class);
&#160;
&#160;&#160; MethodInfo mi = info.getDeclaredMethod(<font color="red">"signature"</font>, <font color="navy"><b>new</b></font> TypeInfo[0]);
&#160;
&#160;&#160; ClassInfo returnInfo = mi.getReturnType(); <font color="darkgreen">//Constructs the parameterized class info internally</font>
&#160;&#160; TypeInfo[] args = returnInfo.getActualTypeArguments(); <font color="darkgreen">//* Lazily loads the type arguments</font>
<font color="navy">}</font>
 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This fails with the call to returnInfo.getActualTypeArguments()</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">java.lang.IllegalStateException: java.lang.ClassNotFoundException: org.jboss.test.classinfo.test.JavassistParameterizedClassInfoClassLoaderArgumentsTestCaseWithSignature
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:840)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.createTypeInfoForTypeArgument(JavassistTypeInfoFactoryImpl.java:898)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistParameterizedClassInfo.getActualTypeArguments(JavassistParameterizedClassInfo.java:115)
&#160;&#160; ....
Caused by: java.lang.ClassNotFoundException: org.jboss.test.classinfo.test.JavassistParameterizedClassInfoClassLoaderArgumentsTestCaseWithSignature
&#160;&#160;&#160;&#160;&#160;at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
&#160;&#160;&#160;&#160;&#160;at java.security.AccessController.doPrivileged(Native Method)
&#160;&#160;&#160;&#160;&#160;at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
&#160;&#160;&#160;&#160;&#160;at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
&#160;&#160;&#160;&#160;&#160;at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
&#160;&#160;&#160;&#160;&#160;at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
&#160;&#160;&#160;&#160;&#160;at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
&#160;&#160;&#160;&#160;&#160;at java.lang.Class.forName0(Native Method)
&#160;&#160;&#160;&#160;&#160;at java.lang.Class.forName(Class.java:247)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.resolveComplexTypeInfo(IntrospectionTypeInfoFactoryImpl.java:434)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.getTypeInfo(IntrospectionTypeInfoFactoryImpl.java:390)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory.getTypeInfo(IntrospectionTypeInfoFactory.java:54)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.delegateToIntrospectionImplementation(JavassistTypeInfoFactoryImpl.java:620)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:547)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:454)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:411)
&#160;&#160;&#160;&#160;&#160;at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:836)
&#160;&#160;&#160;&#160;&#160;... 23 more

</code></pre><p>The reason is that I am using the classloader of the raw type (i.e. Set) to load up this parameterized type, but obviously SomeValue cannot be found there. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>One way around this would be in mi.getReturnType() when looking up/creating/caching the parameterized class info to use the classloader of mi.getDeclaringClass().getClassLoader(), which should be able to see all the classes involved. However, I am still stuck on which classloader to use for my previous post.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/539766#539766">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Microcontainer Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2115">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>