<div dir="ltr">Guys chill about the shading :)  That was only ever mentioned as a preference over the original suggestion to copy large number of classes from Javassist into Hibernate source.  I simply said that if we are copying these classes from Javassist that shading would be a better option for achieving that.  Neither of those are really good options, but forced to choose between the 2 I&#39;d chose shading.<div><br></div><div>I think we all agree that (if possible) Hibernate not using using Javassist at all beyond actually generating the proxy and/or enhancing would be the best option.  So if this is possible lets go that route.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Feb 18, 2016 at 12:17 PM Carlo de Wolf &lt;<a href="mailto:cdewolf@redhat.com">cdewolf@redhat.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looks to me like Hibernate is exposing bad proxies to the user.<br>
<br>
Would it not be possible to use a custom class loader at the point where<br>
the proxy is defined?<br>
Than you could use one that takes the version of javassist that<br>
Hibernate requires and delegates everything else to the deployment class<br>
loader.<br>
<br>
I don&#39;t like to see any sort of shading as this means the full<br>
maintenance burden of those classes are carried over into Hibernate.<br>
<br>
Carlo<br>
<br>
On 02/18/2016 12:11 PM, Sanne Grinovero wrote:<br>
&gt; It seems we&#39;re discussing this issue in multiple places,<br>
&gt; so to let you all know I&#39;ll repeat it hare:<br>
&gt; I think shading is a really really bad idea :)<br>
&gt;<br>
&gt; Could we try to have the enhanced entities to not need Javassist in in<br>
&gt; their *direct* classloader; we can still have a normal Javassist as a<br>
&gt; module dependency of Hibernate?<br>
&gt; That would require to just make sure the generated bytecode doesn&#39;t<br>
&gt; directly refer to Javassist types but uses an indirection controlled<br>
&gt; by Hibernate code.. which in turn can use Javassist or even<br>
&gt; alternatives in future, if we&#39;d like to experiment.<br>
&gt;<br>
&gt; I&#39;m not familiar enough with Javassist to know if that&#39;s an option<br>
&gt; as-is but we can either improve Javassist to allow such a thing or use<br>
&gt; some alternatives, like Gunnar and Hardy also suggested on the<br>
&gt; hibernate-dev mailing list.<br>
&gt;<br>
&gt; To summarize, I agree with Stuart and would hope that Scott&#39;s branch<br>
&gt; can be improved by minimizing the amount of Javassist code which<br>
&gt; actually needs to be copied by using some simple delegation to<br>
&gt; Hibernte types, which in turn can use a private, non-shaded Javassist<br>
&gt; taking advantage of the isolation provided by JBoss Modules.<br>
&gt;<br>
&gt; --Sanne<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On 12 February 2016 at 03:19, Scott Marlow &lt;<a href="mailto:smarlow@redhat.com" target="_blank">smarlow@redhat.com</a>&gt; wrote:<br>
&gt;&gt; What if Javassist packaged these same (proxy/runtime) classes in a<br>
&gt;&gt; separate javassist-runtime jar and we shaded only the proxy/runtime<br>
&gt;&gt; classes?  That way we only repackage the same classes that we included<br>
&gt;&gt; for this hack test (e.g.<br>
&gt;&gt; org.hibernate.bytecode.internal.javassist.proxy.*).<br>
&gt;&gt;<br>
&gt;&gt; Early testing results of the hack test look good<br>
&gt;&gt; (<a href="https://gist.github.com/scottmarlow/ad878968c5a7c6fbbfb7" rel="noreferrer" target="_blank">https://gist.github.com/scottmarlow/ad878968c5a7c6fbbfb7</a>).<br>
&gt;&gt;<br>
&gt;&gt; Scott<br>
&gt;&gt;<br>
&gt;&gt; On 02/11/2016 09:04 PM, Stuart Douglas wrote:<br>
&gt;&gt;&gt; It depends if you are going to shade all the javassist classes or just<br>
&gt;&gt;&gt; the &quot;javassist.util.proxy&quot; package (not sure if this is actually<br>
&gt;&gt;&gt; possible with the shade plugin).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The main advantage is that you can upgrade javassist to get fixes to<br>
&gt;&gt;&gt; issues that affect bytecode generation. So if JDK9 comes out with new<br>
&gt;&gt;&gt; bytecodes that the current version of Javassist does not understand then<br>
&gt;&gt;&gt; upgrading javassist will allow the older version of hibernate to work<br>
&gt;&gt;&gt; with classes compiled against the newer JDK version. If all of javassist<br>
&gt;&gt;&gt; is shaded into hibernate then that version of hibernate will never work<br>
&gt;&gt;&gt; with the newer bytecodes.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I think this is less of an issue if you are still publishing the<br>
&gt;&gt;&gt; non-Javassist shaded hibernate as well as a shaded version, but if the<br>
&gt;&gt;&gt; only published artifact has javassist shaded in then it may limit<br>
&gt;&gt;&gt; forward compatibility.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Stuart<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Fri, 12 Feb 2016 at 12:53 Steve Ebersole &lt;<a href="mailto:steve@hibernate.org" target="_blank">steve@hibernate.org</a><br>
&gt;&gt;&gt; &lt;mailto:<a href="mailto:steve@hibernate.org" target="_blank">steve@hibernate.org</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;      Ugh.  That is an awful lot of classes copied over.  What exactly was<br>
&gt;&gt;&gt;      the benefit of this over shading again?  I mean both case lose the<br>
&gt;&gt;&gt;      ability to simply drop in fixes from upstream Javassist.  So what<br>
&gt;&gt;&gt;      does this &quot;clone&quot; approach gain versus shadowing?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;      On Thu, Feb 11, 2016 at 7:13 PM Scott Marlow &lt;<a href="mailto:smarlow@redhat.com" target="_blank">smarlow@redhat.com</a><br>
&gt;&gt;&gt;      &lt;mailto:<a href="mailto:smarlow@redhat.com" target="_blank">smarlow@redhat.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;           &gt;&gt;<br>
&gt;&gt;&gt;           &gt;&gt;      On 02/11/2016 03:02 PM, Stuart Douglas wrote:<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; Have you considered a 3rd alternative, which is to<br>
&gt;&gt;&gt;          use a custom<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; ProxyFactory instead of javassists built in one?<br>
&gt;&gt;&gt;           &gt;&gt;       &gt;<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; AFAIK the main issue is that javassist proxies<br>
&gt;&gt;&gt;          require access to the<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; &#39;javassist.util.proxy.MethodHandler|RuntimeSupport&#39;<br>
&gt;&gt;&gt;          classes. You<br>
&gt;&gt;&gt;           &gt;&gt;      could<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; create a similar org.hibernate interface, and a<br>
&gt;&gt;&gt;          proxy factory<br>
&gt;&gt;&gt;           &gt;&gt;      that uses<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; this method handler instead.<br>
&gt;&gt;&gt;           &gt;&gt;       &gt;<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; Basically you just copy the code from<br>
&gt;&gt;&gt;          javassist.util.proxy into<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; hibernate. This is a relatively small amount of<br>
&gt;&gt;&gt;          code, so it<br>
&gt;&gt;&gt;           &gt;&gt;      should not<br>
&gt;&gt;&gt;           &gt;&gt;       &gt; really add any maintenance burden.<br>
&gt;&gt;&gt;           &gt;&gt;<br>
&gt;&gt;&gt;           &gt;&gt;      We talked about this as well via [1].  I understand the<br>
&gt;&gt;&gt;          concept but have<br>
&gt;&gt;&gt;           &gt;&gt;      not tried doing this.  I like this approach as well, if<br>
&gt;&gt;&gt;          it works.  One<br>
&gt;&gt;&gt;           &gt;&gt;      of the cons with cloning that Steve Ebersole pointed<br>
&gt;&gt;&gt;          out (see response<br>
&gt;&gt;&gt;           &gt;&gt;      on Feb-03-2016 9:01am), is that that users lose the<br>
&gt;&gt;&gt;          ability to drop a<br>
&gt;&gt;&gt;           &gt;&gt;      different version of Javassist in (since we maintain<br>
&gt;&gt;&gt;          our own cloned copy<br>
&gt;&gt;&gt;           &gt;&gt;      of the Javassist proxy/runtime code).<br>
&gt;&gt;&gt;           &gt;&gt;<br>
&gt;&gt;&gt;           &gt;&gt;<br>
&gt;&gt;&gt;           &gt;&gt; The proxy code is a relatively small part of javassist, so<br>
&gt;&gt;&gt;          unless a bug<br>
&gt;&gt;&gt;           &gt;&gt; is in the proxy code itself this should not be that big a deal.<br>
&gt;&gt;&gt;           &gt;<br>
&gt;&gt;&gt;           &gt; Thanks for the encouragement to go down this path.  :)<br>
&gt;&gt;&gt;           &gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;          Started a hack attempt at the clone via<br>
&gt;&gt;&gt;          <a href="https://github.com/scottmarlow/hibernate-orm/tree/javassistproxy" rel="noreferrer" target="_blank">https://github.com/scottmarlow/hibernate-orm/tree/javassistproxy</a>.<br>
&gt;&gt;&gt;          Seems<br>
&gt;&gt;&gt;          to pass the Hibernate ORM unit tests.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;          Scott<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;          _______________________________________________<br>
&gt;&gt;&gt;          wildfly-dev mailing list<br>
&gt;&gt;&gt;          <a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;          <a href="https://lists.jboss.org/mailman/listinfo/wildfly-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/wildfly-dev</a><br>
&gt;&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; wildfly-dev mailing list<br>
&gt;&gt; <a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/wildfly-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/wildfly-dev</a><br>
&gt; _______________________________________________<br>
&gt; wildfly-dev mailing list<br>
&gt; <a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/wildfly-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/wildfly-dev</a><br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
wildfly-dev mailing list<br>
<a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/wildfly-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/wildfly-dev</a><br>
</blockquote></div>