Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17137

Java 10: "Illegal method name" when test functions in Kotlin contain spaces in name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 5.0.5
    • Fix Version/s: 5.1 RC3
    • Component/s: Test
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      // Kotlin code:
      
      @RunWith(SpringRunner::class)
      @JooqTest
      class Test {    
      
          fun `this will fail`() {  }
      
      }
      

       

      Running this Kotlin test in a java 9 or 10 environment throws the following error:

      org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class Test]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null	at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:209)
      	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
      	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:473)
      	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:355)
      	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:304)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:413)
      	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:119)
      	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
      	at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44)
      	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
      	at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:345)
      	at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:492)
      	at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
      	at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
      	at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
      	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
      	at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
      	at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
      	at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
      	at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
      	at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
      	at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:337)
      	at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:58)
      	at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205)
      	... 31 more
      Caused by: java.lang.reflect.InvocationTargetException
      	at java.base/jdk.internal.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      	at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:459)
      	at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
      	... 45 more
      Caused by: java.lang.ClassFormatError: Illegal method name "this will fail" in class Test$$EnhancerBySpringCGLIB$$9a76c928
      	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
      	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1007)
      	... 50 more
      

       

      It doesn't matter if @JooqTest or @DataJpaTest is used. As soon as Spring attempts to proxy (with the transaction handler) the test class it fails.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              mcescher Ömer Yildiz
              Last updater:
              Spring Issues
              Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 41 weeks, 1 day ago