[hibernate-dev] clone a lazy-init Object

Steve Ebersole steve at hibernate.org
Tue Jun 23 10:20:24 EDT 2009


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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
-- 
Steve Ebersole <steve at hibernate.org>
Hibernate.org




More information about the hibernate-dev mailing list