I just wanted to make the hibernate team aware of this bug, so that the javassist library
shipping with hibernate can be updated on occasion if there are no objections to that
change.
I was also wondering, if there is a reason one should not use clones of
Hibernate-instantiated objects, because I was puzzled this has not hit too many others
before.
-----Ursprüngliche Nachricht-----
Von: Steve Ebersole [mailto:steven.ebersole@gmail.com] Im Auftrag von Steve Ebersole
Gesendet: Dienstag, 23. Juni 2009 16:20
An: Tobias Meyer
Cc: hibernate-dev(a)lists.jboss.org
Betreff: Re: [hibernate-dev] clone a lazy-init Object
Note sure what you are actually asking.
Sure it seems like incorrect behavior from javassist...
On Tue, 2009-06-23 at 15:36 +0200, Tobias Meyer wrote:
Hello List,
we ran into a problem with javassist when recently upgrading to
hibernate 3.3.1.GA, whid did not occur with the previous cglib
implementation.
We sometimes make use of the cloneable interface and therefore have
declared a public clone() on some objects.
If those objects are initially loaded lazily, even if they are fully
initialized later on, a call to the clone() method will result in a
java.lang.IllegalAccessError at runtime.
This is caused by the Javassist proxy, which exposes the protected
clone() of java.lang.Object instead of the public definition from the
interface, which I believe to be a bug.
I submitted a proposed fix for this at
https://jira.jboss.org/jira/browse/JASSIST-85
The result of the fix is, that the clone method of the target is
called, which returns a cloned instance of the target object (not a
clone of the proxy object), which is exactly what we need.
Maybe someone can give their 2 cent if this is actually desired
behavior or if this could cause unwanted side-effects.
I believe it's in every case better than the current state (runtime
errors), and others seem to have had similar issues as well
(see HHH-1726 and
http://preview.tinyurl.com/mpnz9p)
Kind regards
Tobias Meyer
_______________________________________________
hibernate-dev mailing list
hibernate-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev --
Steve Ebersole <steve(a)hibernate.org>
Hibernate.org