java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public java.util.List SimpleGroovyBean.get$lazyloaded()'

Spring JIRA | Lari Hotari | 8 years ago
  1. 0

    I'm using the new @Lazy AST transformation available in Groovy 1.6 for creating thread safe lazy loading properties . @Lazy GroovyDoc: http://groovy.codehaus.org/gapi/groovy/lang/Lazy.html , http://groovy.codehaus.org/gapi/org/codehaus/groovy/transform/LazyASTTransformation.html LazyASTTransformation source code: http://fisheye.codehaus.org/browse/groovy/branches/GROOVY_1_6_0/src/main/org/codehaus/groovy/transform/LazyASTTransformation.java?r=13570 My problem is in a Grails 1.1 application which uses Spring's BeanWrapper. I've also reported the problem to Grails JIRA (http://jira.codehaus.org/browse/GRAILS-4192). Calling BeanWrapperImpl.getPropertyDescriptors() fails with IllegalStateException. ("Unable to locate bridged method for bridge method...") in BridgeMethodResolver. The problem appears _only_ when "@Lazy volatile" is used (creates thread safe lazy initialization). A property annotated with @Lazy but without volatile succeeds. Workaround to the problem: I checked the LazyASTTransformation source code (while I was writing this issue) and happened to test adding "private" to the @Lazy volatile property (private @Lazy volatile) and that works. I've created a simple test case for this problem: SimpleGroovyBean.groovy: public class SimpleGroovyBean{ String name @Lazy volatile List lazyloaded={ ['some','items','in','the','list'] }() @Lazy List lazyloadedNoProblem={ ['no','problem'] }() private @Lazy volatile List lazyloadedVolatileNoProblem={ ['no','problem','when','private'] }() } SimpleGroovyBeanTest.groovy: import groovy.util.GroovyTestCase import junit.framework.TestCase import org.springframework.beans.BeanWrapperImpl public class SimpleGroovyBeanTest extends GroovyTestCase { public void testBeanWrapper() { def bean = new SimpleGroovyBean() def beanWrapper = new BeanWrapperImpl(bean) assertNotNull(beanWrapper.getPropertyDescriptors()) } } Stack trace: java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public java.util.List SimpleGroovyBean.get$lazyloaded()' at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:77) at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:58) at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:246) at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:143) at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:251) at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:258) 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 org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at SimpleGroovyBeanTest.testBeanWrapper(SimpleGroovyBeanTest.groovy:9) 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:164)

    Spring JIRA | 8 years ago | Lari Hotari
    java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public java.util.List SimpleGroovyBean.get$lazyloaded()'
  2. 0

    I'm using the new @Lazy AST transformation available in Groovy 1.6 for creating thread safe lazy loading properties . @Lazy GroovyDoc: http://groovy.codehaus.org/gapi/groovy/lang/Lazy.html , http://groovy.codehaus.org/gapi/org/codehaus/groovy/transform/LazyASTTransformation.html LazyASTTransformation source code: http://fisheye.codehaus.org/browse/groovy/branches/GROOVY_1_6_0/src/main/org/codehaus/groovy/transform/LazyASTTransformation.java?r=13570 My problem is in a Grails 1.1 application which uses Spring's BeanWrapper. I've also reported the problem to Grails JIRA (http://jira.codehaus.org/browse/GRAILS-4192). Calling BeanWrapperImpl.getPropertyDescriptors() fails with IllegalStateException. ("Unable to locate bridged method for bridge method...") in BridgeMethodResolver. The problem appears _only_ when "@Lazy volatile" is used (creates thread safe lazy initialization). A property annotated with @Lazy but without volatile succeeds. Workaround to the problem: I checked the LazyASTTransformation source code (while I was writing this issue) and happened to test adding "private" to the @Lazy volatile property (private @Lazy volatile) and that works. I've created a simple test case for this problem: SimpleGroovyBean.groovy: public class SimpleGroovyBean{ String name @Lazy volatile List lazyloaded={ ['some','items','in','the','list'] }() @Lazy List lazyloadedNoProblem={ ['no','problem'] }() private @Lazy volatile List lazyloadedVolatileNoProblem={ ['no','problem','when','private'] }() } SimpleGroovyBeanTest.groovy: import groovy.util.GroovyTestCase import junit.framework.TestCase import org.springframework.beans.BeanWrapperImpl public class SimpleGroovyBeanTest extends GroovyTestCase { public void testBeanWrapper() { def bean = new SimpleGroovyBean() def beanWrapper = new BeanWrapperImpl(bean) assertNotNull(beanWrapper.getPropertyDescriptors()) } } Stack trace: java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public java.util.List SimpleGroovyBean.get$lazyloaded()' at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:77) at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:58) at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:246) at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:143) at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:251) at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:258) 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 org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at SimpleGroovyBeanTest.testBeanWrapper(SimpleGroovyBeanTest.groovy:9) 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:164)

    Spring JIRA | 8 years ago | Lari Hotari
    java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public java.util.List SimpleGroovyBean.get$lazyloaded()'
  3. 0

    What I did is just write an unit test by both groovy and java: A java wroted super class: ------------------------------------- @RunWith(SpringJUnit4ClassRunner.class) @Transactional @TransactionConfiguration(transactionManager = "hb3TransactionManager") @ContextConfiguration(locations = { "classpath:spring/applicationContext-global.xml", "classpath:spring/applicationContext-mail.xml"}) public class AbstractErpServiceTest { protected final static String COUNTRY_ID = "CAN"; @Autowired private GeoService geoService; .... ------------------------------------ A groovy wrote subclass : ------------------------------- class ActivityManagerTest extends AbstractErpServiceTest { @Autowired private CallManager callManager ... --------------------------------------------- When I use run it in my eclipse JUnit plugin, I got the exception: like this: ---------------------------------------- 2009-11-06 15:52:25,826 [main] ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@153ca5] to prepare test instance [com.oppa.crm.test.service.ActivityManagerTest@1c8f5b9] java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public void com.oppa.crm.test.service.ActivityManagerTest.this$dist$set$3(java.lang.String,java.lang.Object)' at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:77) [org.springframework.core-3.0.0.RC1.jar:3.0.0.RC1] --------------------------------------------------- Actually, I works before when I use the plugin with groovy 1.6.4, but after I update to 1.6.5 or 1.7, I got these exceptions. Summary, groovy unit text cannot work with these together now: @RunWith(SpringJUnit4ClassRunner.class) @Transactional @TransactionConfiguration @ContextConfiguration Hope anyone here could help me, thanks.

    Spring JIRA | 7 years ago | Lei Zhang
    java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public void com.oppa.crm.test.service.ActivityManagerTest.this$dist$set$3(java.lang.String,java.lang.Object)'
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    What I did is just write an unit test by both groovy and java: A java wroted super class: ------------------------------------- @RunWith(SpringJUnit4ClassRunner.class) @Transactional @TransactionConfiguration(transactionManager = "hb3TransactionManager") @ContextConfiguration(locations = { "classpath:spring/applicationContext-global.xml", "classpath:spring/applicationContext-mail.xml"}) public class AbstractErpServiceTest { protected final static String COUNTRY_ID = "CAN"; @Autowired private GeoService geoService; .... ------------------------------------ A groovy wrote subclass : ------------------------------- class ActivityManagerTest extends AbstractErpServiceTest { @Autowired private CallManager callManager ... --------------------------------------------- When I use run it in my eclipse JUnit plugin, I got the exception: like this: ---------------------------------------- 2009-11-06 15:52:25,826 [main] ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@153ca5] to prepare test instance [com.oppa.crm.test.service.ActivityManagerTest@1c8f5b9] java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public void com.oppa.crm.test.service.ActivityManagerTest.this$dist$set$3(java.lang.String,java.lang.Object)' at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:77) [org.springframework.core-3.0.0.RC1.jar:3.0.0.RC1] --------------------------------------------------- Actually, I works before when I use the plugin with groovy 1.6.4, but after I update to 1.6.5 or 1.7, I got these exceptions. Summary, groovy unit text cannot work with these together now: @RunWith(SpringJUnit4ClassRunner.class) @Transactional @TransactionConfiguration @ContextConfiguration Hope anyone here could help me, thanks.

    Spring JIRA | 7 years ago | Lei Zhang
    java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public void com.oppa.crm.test.service.ActivityManagerTest.this$dist$set$3(java.lang.String,java.lang.Object)'
  6. 0

    Scala 2.9 Bridge-Method

    Stack Overflow | 5 years ago | shj
    java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public void com.app.messaging.JmsPublisher.debug(java.lang.String, scala.collection.Seq)'

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Unable to locate bridged method for bridge method 'public java.util.List SimpleGroovyBean.get$lazyloaded()'

      at org.springframework.core.BridgeMethodResolver.findBridgedMethod()
    2. Spring Core
      BridgeMethodResolver.findBridgedMethod
      1. org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:77)
      1 frame
    3. Spring Beans
      BeanWrapperImpl.getPropertyDescriptors
      1. org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:58)
      2. org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:246)
      3. org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:143)
      4. org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:251)
      5. org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:258)
      5 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    5. Groovy
      AbstractCallSite.call
      1. org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
      2. org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
      3. org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43)
      4. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      5. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
      5 frames
    6. Unknown
      SimpleGroovyBeanTest.testBeanWrapper
      1. SimpleGroovyBeanTest.testBeanWrapper(SimpleGroovyBeanTest.groovy:9)
      1 frame
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    8. JUnit
      TestCase.runTest
      1. junit.framework.TestCase.runTest(TestCase.java:164)
      1 frame