<!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;">
    Issues using Javassist TypeInfoFactory in other projects
</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/534602#534602">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Another issue is that dynamically created classes are not found in the classpools.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Dynamic proxies are not found at all:</p><p>0 DEBUG [JDKLazyInstantiationTestCase] ==== setUp org.jboss.test.kernel.lazy.test.JDKLazyInstantiationTestCase ====</p><p>5 DEBUG [JDKLazyInstantiationTestCase] ==== Starting testLazy ====</p><p>20 DEBUG [KernelFactory] Starting JBoss Kernel construction...</p><p>53 WARN&#160; [PropertyConfiguration] Factory: org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory@4393722c</p><p>466 DEBUG [KernelFactory] Completed JBoss Kernel construction.&#160; Duration: 446 milliseconds</p><p>568 ERROR [AbstractKernelController] Error installing to Instantiated: name=beanProxy state=Described</p><p>java.lang.RuntimeException: Class not found: $Proxy0</p><p>at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:311)</p><p>at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:519)</p><p>at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory.getTypeInfo(JavassistTypeInfoFactory.java:51)</p><p>at org.jboss.classadapter.plugins.BasicClassAdapterFactory.getClassAdapter(BasicClassAdapterFactory.java:54)</p><div> </div><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Neither are the javassist ProxyFactory proxies, since they just define the class in the classloader with no way to find them from the pools:</p><p>0 DEBUG [JavassistLazyInstantiationTestCase] ==== setUp org.jboss.test.kernel.lazy.test.JavassistLazyInstantiationTestCase ====</p><p>3 DEBUG [JavassistLazyInstantiationTestCase] ==== Starting testLazy ====</p><p>18 DEBUG [KernelFactory] Starting JBoss Kernel construction...</p><p>47 WARN&#160; [PropertyConfiguration] Factory: org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory@4393722c</p><p>514 DEBUG [KernelFactory] Completed JBoss Kernel construction.&#160; Duration: 496 milliseconds</p><p>618 ERROR [AbstractKernelController] Error installing to Instantiated: name=beanProxy state=Described</p><p>java.lang.RuntimeException: Class not found: org.jboss.test.kernel.lazy.support.IRare_$$_javassist_0</p><p>at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:311)</p><p>at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:519)</p><p>at org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory.getTypeInfo(JavassistTypeInfoFactory.java:51)</p><p>at org.jboss.classadapter.plugins.BasicClassAdapterFactory.getClassAdapter(BasicClassAdapterFactory.java:54)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In AOP what we did was to write the class bytes to the in memory vfs location from the aop classpools, so that when trying to look up the CtClass later there is a resource path for the class bytes:</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; URL outputURL = <font color="navy"><b>new</b></font> URL(tempURL.toString() + <font color="red">"/"</font> + classFileName);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//Write the classfile to the temporary url</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>synchronized</b></font> (tmplock)
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>if</b></font> (trace) logger.trace(<font color="navy"><b>this</b></font> + <font color="red">" "</font> + pool + <font color="red">".toClass() myloader:"</font> + myloader + <font color="red">" writing bytes to "</font> + tempURL);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ByteArrayOutputStream byteout = <font color="navy"><b>new</b></font> ByteArrayOutputStream();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BufferedOutputStream out = <font color="navy"><b>new</b></font> BufferedOutputStream(byteout);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; out.write(cc.toBytecode());
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; out.flush();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; out.close();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>byte</b></font>[] classBytes = byteout.toByteArray();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MemoryContextFactory factory = MemoryContextFactory.getInstance();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; factory.putFile(outputURL, classBytes);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Going to check with Chiba, but I'll see if I can modify javassist to allow ProxyFactory and ProxyFactoryHelper to accept an interface like</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>interface</b></font> ByteRecorder<font color="navy">{</font>
&#160;&#160; <font color="navy"><b>void</b></font> writeBytes(String classname, <font color="navy"><b>byte</b></font>[]) <font color="navy"><b>throws</b></font> IOException
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><div> </div><div> </div></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/534602#534602">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>