<div dir="ltr">This is definitely an interesting option. I actually think the same could be achieved with Javassist too however. That said, Javassist definitely has drawbacks. I am not familiar with <span style="font-size:13px;line-height:21.6667px">ByteBuddy.</span><div><span style="line-height:21.6667px"><br></span><div><br><div class="gmail_quote"><div dir="ltr">On Thu, Feb 18, 2016 at 5:35 AM Gunnar Morling <<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">My branch at <a href="https://github.com/gunnarmorling/hibernate-orm/tree/HHH-10536" rel="noreferrer" target="_blank">https://github.com/gunnarmorling/hibernate-orm/tree/HHH-10536</a><br>
is exactly doing this (using ByteBuddy).<br>
<br>
Generated proxy types invoke java.lang.reflect.InvocationHandler, i.e.<br>
no dependency to any library. Of course the same could be done either<br>
using ASM directly or ripping ProxyFactory out of Javassist and adapt<br>
it to do the same.<br>
<br>
--Gunnar<br>
<br>
<br>
2016-02-18 12:11 GMT+01:00 Sanne Grinovero <<a href="mailto:sanne@hibernate.org" target="_blank">sanne@hibernate.org</a>>:<br>
> It seems we're discussing this issue in multiple places,<br>
> so to let you all know I'll repeat it hare:<br>
> I think shading is a really really bad idea :)<br>
><br>
> Could we try to have the enhanced entities to not need Javassist in in<br>
> their *direct* classloader; we can still have a normal Javassist as a<br>
> module dependency of Hibernate?<br>
> That would require to just make sure the generated bytecode doesn't<br>
> directly refer to Javassist types but uses an indirection controlled<br>
> by Hibernate code.. which in turn can use Javassist or even<br>
> alternatives in future, if we'd like to experiment.<br>
><br>
> I'm not familiar enough with Javassist to know if that's an option<br>
> as-is but we can either improve Javassist to allow such a thing or use<br>
> some alternatives, like Gunnar and Hardy also suggested on the<br>
> hibernate-dev mailing list.<br>
><br>
> To summarize, I agree with Stuart and would hope that Scott's branch<br>
> can be improved by minimizing the amount of Javassist code which<br>
> actually needs to be copied by using some simple delegation to<br>
> Hibernte types, which in turn can use a private, non-shaded Javassist<br>
> taking advantage of the isolation provided by JBoss Modules.<br>
><br>
> --Sanne<br>
><br>
><br>
><br>
> On 12 February 2016 at 03:19, Scott Marlow <<a href="mailto:smarlow@redhat.com" target="_blank">smarlow@redhat.com</a>> wrote:<br>
>> What if Javassist packaged these same (proxy/runtime) classes in a<br>
>> separate javassist-runtime jar and we shaded only the proxy/runtime<br>
>> classes? That way we only repackage the same classes that we included<br>
>> for this hack test (e.g.<br>
>> org.hibernate.bytecode.internal.javassist.proxy.*).<br>
>><br>
>> Early testing results of the hack test look good<br>
>> (<a href="https://gist.github.com/scottmarlow/ad878968c5a7c6fbbfb7" rel="noreferrer" target="_blank">https://gist.github.com/scottmarlow/ad878968c5a7c6fbbfb7</a>).<br>
>><br>
>> Scott<br>
>><br>
>> On 02/11/2016 09:04 PM, Stuart Douglas wrote:<br>
>>> It depends if you are going to shade all the javassist classes or just<br>
>>> the "javassist.util.proxy" package (not sure if this is actually<br>
>>> possible with the shade plugin).<br>
>>><br>
>>> The main advantage is that you can upgrade javassist to get fixes to<br>
>>> issues that affect bytecode generation. So if JDK9 comes out with new<br>
>>> bytecodes that the current version of Javassist does not understand then<br>
>>> upgrading javassist will allow the older version of hibernate to work<br>
>>> with classes compiled against the newer JDK version. If all of javassist<br>
>>> is shaded into hibernate then that version of hibernate will never work<br>
>>> with the newer bytecodes.<br>
>>><br>
>>> I think this is less of an issue if you are still publishing the<br>
>>> non-Javassist shaded hibernate as well as a shaded version, but if the<br>
>>> only published artifact has javassist shaded in then it may limit<br>
>>> forward compatibility.<br>
>>><br>
>>> Stuart<br>
>>><br>
>>><br>
>>> On Fri, 12 Feb 2016 at 12:53 Steve Ebersole <<a href="mailto:steve@hibernate.org" target="_blank">steve@hibernate.org</a><br>
>>> <mailto:<a href="mailto:steve@hibernate.org" target="_blank">steve@hibernate.org</a>>> wrote:<br>
>>><br>
>>> Ugh. That is an awful lot of classes copied over. What exactly was<br>
>>> the benefit of this over shading again? I mean both case lose the<br>
>>> ability to simply drop in fixes from upstream Javassist. So what<br>
>>> does this "clone" approach gain versus shadowing?<br>
>>><br>
>>><br>
>>><br>
>>> On Thu, Feb 11, 2016 at 7:13 PM Scott Marlow <<a href="mailto:smarlow@redhat.com" target="_blank">smarlow@redhat.com</a><br>
>>> <mailto:<a href="mailto:smarlow@redhat.com" target="_blank">smarlow@redhat.com</a>>> wrote:<br>
>>><br>
>>> >><br>
>>> >> On 02/11/2016 03:02 PM, Stuart Douglas wrote:<br>
>>> >> > Have you considered a 3rd alternative, which is to<br>
>>> use a custom<br>
>>> >> > ProxyFactory instead of javassists built in one?<br>
>>> >> ><br>
>>> >> > AFAIK the main issue is that javassist proxies<br>
>>> require access to the<br>
>>> >> > 'javassist.util.proxy.MethodHandler|RuntimeSupport'<br>
>>> classes. You<br>
>>> >> could<br>
>>> >> > create a similar org.hibernate interface, and a<br>
>>> proxy factory<br>
>>> >> that uses<br>
>>> >> > this method handler instead.<br>
>>> >> ><br>
>>> >> > Basically you just copy the code from<br>
>>> javassist.util.proxy into<br>
>>> >> > hibernate. This is a relatively small amount of<br>
>>> code, so it<br>
>>> >> should not<br>
>>> >> > really add any maintenance burden.<br>
>>> >><br>
>>> >> We talked about this as well via [1]. I understand the<br>
>>> concept but have<br>
>>> >> not tried doing this. I like this approach as well, if<br>
>>> it works. One<br>
>>> >> of the cons with cloning that Steve Ebersole pointed<br>
>>> out (see response<br>
>>> >> on Feb-03-2016 9:01am), is that that users lose the<br>
>>> ability to drop a<br>
>>> >> different version of Javassist in (since we maintain<br>
>>> our own cloned copy<br>
>>> >> of the Javassist proxy/runtime code).<br>
>>> >><br>
>>> >><br>
>>> >> The proxy code is a relatively small part of javassist, so<br>
>>> unless a bug<br>
>>> >> is in the proxy code itself this should not be that big a deal.<br>
>>> ><br>
>>> > Thanks for the encouragement to go down this path. :)<br>
>>> ><br>
>>><br>
>>> Started a hack attempt at the clone via<br>
>>> <a href="https://github.com/scottmarlow/hibernate-orm/tree/javassistproxy" rel="noreferrer" target="_blank">https://github.com/scottmarlow/hibernate-orm/tree/javassistproxy</a>.<br>
>>> Seems<br>
>>> to pass the Hibernate ORM unit tests.<br>
>>><br>
>>> Scott<br>
>>><br>
>>> _______________________________________________<br>
>>> wildfly-dev mailing list<br>
>>> <a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a> <mailto:<a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a>><br>
>>><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>
>>><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>
> _______________________________________________<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>
_______________________________________________<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></div></div></div>