[hibernate-dev] clone a lazy-init Object
tm at allocation.net
Tue Jun 23 09:36:53 EDT 2009
we ran into a problem with javassist when recently upgrading to
hibernate 3.3.1.GA, whid did not occur with the previous cglib
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
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)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hibernate-dev