-->
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.  [ 4 posts ] 
Author Message
 Post subject: strange cglib 'IllegalArgumentException: Protected method'
PostPosted: Tue Mar 15, 2005 7:27 am 
Newbie

Joined: Mon Mar 14, 2005 2:57 pm
Posts: 16
I have an entity class Container with a parent child relationship with other containers using a setParent method.

public void setParent(Container parent) {
if( parent != null) {
if( this.parent != null)
this.parent.removeChild(this);

parent.addChild(this);
this.parent = parent;
}
}

I use 2 protected methods (addChild and removeChild) to implement polymorphic behaviour, but i get 'java.lang.IllegalArgumentException: Protected method: removeChild(Lexodus/ecentric/model/Node;)V' error. The strange thing is that if I change the visibility to the default package access everything works correctly.

This is strange because the package access is more strict than protected.

Any ideas?

Hibernate version: 3.0 rc1

Full stack trace of any exception that occurs:
java.lang.IllegalArgumentException: Protected method: removeChild(Lexodus/ecentric/model/Node;)V
at net.sf.cglib.proxy.MethodProxy$1.invoke(MethodProxy.java:55)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at exodus.ecentric.model.Container$$EnhancerByCGLIB$$1760e8c5.removeChild(<generated>)
at exodus.ecentric.model.Node.setParent(Node.java:181)
at exodus.ecentric.model.RecycleBin.delete(RecycleBin.java:48)
at exodus.ecentric.test.EntityTest.testMoveToRecycleBin(EntityTest.java:501)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at exodus.model.test.TestCase.runTest(TestCase.java:60)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 8:17 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Yes, it can intercept protected method, but it can not delegate. I can patch "CGLIBLazyInitializer" to use "setAccessable" if it doe's not seem too aggresive .


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 8:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I'd say yes, try to use setAccessible(), it is better than failing without trying at all.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 9:54 am 
Newbie

Joined: Mon Mar 14, 2005 2:57 pm
Posts: 16
Thanks for the quick reply!

I would be pleased to test again when this fix is applied.

Keep up the good work guys!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.