-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: CGLIBLazyInitializer.intercept() and class that returns self
PostPosted: Thu Feb 10, 2005 6:48 pm 
Beginner
Beginner

Joined: Wed Feb 04, 2004 4:54 am
Posts: 25
Hibernate version:
3.0b3

I've got a lazy object with a method that does "return this;" because that specific instance implement also other interfaces.
When I try to invoke that method I always get a ClassCastException.

Debugging the code I've found this:

CGLIBLazyInitializer
Code:
   public Object intercept(
      final Object obj,
      final Method method,
      final Object[] args,
      final MethodProxy proxy)
   throws Throwable {
      if (constructed) {
         Object result = invoke(method, args, obj);
         if (result==INVOKE_IMPLEMENTATION) {
            Object target = getImplementation();
            Object retval = proxy.invoke(target, args);
   >>>      return (retval==target) ? this : retval;       <<<
         }
         else {
            return result;
         }
      }
      else {
         //while constructor is running
         return proxy.invokeSuper(obj, args);
      }
   }


Well, if the method invoked on target returns target (my use case) then this method return this (the CGLIBLazyInitializer) instead of method return value...

I think it should return "obj" instead of "this"!

Am I right?

_________________
Stefano Bagnara


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 5:53 am 
Beginner
Beginner

Joined: Wed Feb 04, 2004 4:54 am
Posts: 25
I patched my h3b3 sources and now it seems to work.
I opened a JIRA issue, hope this is ok: http://opensource.atlassian.com/project ... se/HHH-136

_________________
Stefano Bagnara


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 6:01 am 
Beginner
Beginner

Joined: Wed Feb 04, 2004 4:54 am
Posts: 25
One more thing:

I added hibernate.cglib.use_reflection_optimizer false to my hibernate.properties but CGLibLazyInizializer is still there (in the runtime exception).

Is this a bug?

_________________
Stefano Bagnara


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 6:10 am 
Beginner
Beginner

Joined: Wed Feb 04, 2004 4:54 am
Posts: 25
bago wrote:
I opened a JIRA issue, hope this is ok: http://opensource.atlassian.com/project ... se/HHH-136


LOL: my estimate for that bug was 5 minutes... this took 13 minutes from 1st bug post to bug fixed.

Thanks to Gavin for the speed!

_________________
Stefano Bagnara


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 6:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This was a bug introduced in 3.0beta. Thanks for finding it.

The second thing isn't a bug, proxies have nothing to do with the reflection optimizer.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 6:16 am 
Beginner
Beginner

Joined: Wed Feb 04, 2004 4:54 am
Posts: 25
gavin wrote:
The second thing isn't a bug, proxies have nothing to do with the reflection optimizer.


That's what I thought, but was not sure..

_________________
Stefano Bagnara


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.