Skip to content

BridgeMethodResolver is unable to locate bridged method for hibernate Cglib-wrapped class implementing a generic interface [SPR-5414] #10088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jan 15, 2009 · 4 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 15, 2009

Arnout Engelen opened SPR-5414 and commented

In some situations (in this case a hibernate-cglib-wrapped class implementing a generic interface), calling 'BeanUtils.getPropertyDescriptor' on any property of the class results in an IllegalStateException.

After some inspection, it seems BridgeMethodResolver recognises 2 candidate functions when looking for the bridge method, but upon closer inspection, decides neither of them should be chosen.

Attached is a simple, reasonable self-contained unittest demonstrating the problem. The problem does not seem to occur in Spring versions prior to 2.5.6.

Tested with hibernate 3.2.6.ga

java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public final void nl.topicuszorg.wicket.hibernate.test.CGLibTest$CglibInstantieMedewerker$$EnhancerByCGLIB$$540fe4f7.setOrganisatie(nl.topicuszorg.wicket.hibernate.test.CGLibTest$CglibIOrganisatie)'
at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:86)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:59)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanUtils.getPropertyDescriptor(BeanUtils.java:329)
at nl.topicuszorg.wicket.hibernate.test.CGLibTest.testCGLib(CGLibTest.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Affects: 2.5.6

Attachments:

Sub-tasks:

Referenced from: commits 15bbd57

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jan 15, 2009

Arnout Engelen commented

This might be related to #7727 , though it looks like that one has been fixed for some time now.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Thanks for pointing this out! This is a bit of strange generics-based arrangement, with IntelliJ IDEA even flagging the leaf subclass as invalid because of no setter being declared for the specific generic type that the subclass declares... That said - IntelliJ then nevertheless compiles the class when forced to! According to the Java compiler, it is valid.

In any case, as of 3.0 M2, Spring's bridge method resolution works with Hibernate-generated CGLIB proxies as well.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Brian Relph commented

Will you be fixing this in the 2.5.x branch?

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This is not scheduled for backporting at present, since we haven't had much chance for researching side effects yet. Also, Spring 3.0 comes with several enhancements that better support the use of generics in bean property methods... So this change is in good company within Spring 3.0 - as part of a larger whole.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants