-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Java 10: "Illegal method name" when test functions in Kotlin contain spaces in name [SPR-17137] #21674
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
Comments
Juergen Hoeller commented A general note: Such latest-infrastructure test arrangements should always be run against the latest Spring Framework version; 5.0.5 seems rather old here. I'm not aware of any particular differences in this area in 5.0.8, but 5.1 RC1 has a revised CGLIB class definition mechanism which might make a difference for this case. That said, if the issue is reproducible against 5.1 RC1 / 5.1.0.BUILD-SNAPSHOT, we'll have to see how Kotlin handles spaces in method names, possibly adopting the same convention at CGLIB level so that the JVM accepts those names even for generated proxy methods. |
Ömer Yildiz commented In order to check it, I've updated my parent's pom to use spring boot 2.1.0.BUILD-SNAPSHOT (which imports spring 5.1 RC1). However, the problem still persists. |
Benjamin Winterberg commented I'm encountering the exact same problem while migrating our product to JDK 10. We use Spring Framework 5.0.8 (no boot), JUnit 5, Kotlin 1.2.60 and cglib-nodeps 3.2.7. Normal method names (without backticks) work as expected but Kotlin backtick method names with spaces result in the exception above. As a workaround you could rename test methods to not use backticks. However we have nearly 1.000 Kotlin Spring tests with a bunch of test names containing special characters such as spaces. It would be quite a lot of work to rename all those tests. Any ETA when you'll work on this issue? Also please let me know if you need more info to reproduce. |
Juergen Hoeller commented Looking at that stacktrace, I'm wondering why there is even a CGLIB proxy generated for the test class in the first place? |
Sébastien Deleuze commented This can be reproduced on https://github.com/spring-guides/tut-spring-boot-kotlin and this is indeed something we need to fix before 5.1 GA. The issue occurs with Boot 2.0 / Framework 5.0 as well so it is likely not a 5.1 regression. |
Juergen Hoeller commented If for any reason we can't fully support spaces in method names for generated proxies quite yet, we should at least avoid the proxy attempt there in the first place. The AOP setup apparently reacts to some general advisor here, trying to proxy the test class itself with it... which is entirely pointless as far as I can tell. |
Davin Kevin commented FYI, this problem doesn't happen on a simple test, without database (like rest endpoint or business logic). The operation made by |
Juergen Hoeller commented Hmm, I suppose Spring's transaction advisor picks up the test instance there, detects implicit transaction annotations on it (as meta-annotations on those stereotype annotations) and therefore tries to proxy it... with the proxy subsequently ignored but nevertheless causing a failure here. This doesn't make sense at all: We need to figure out how to suppress the proxy attempt there to begin with. |
Juergen Hoeller commented I've introduced an "original instance" convention to |
Juergen Hoeller commented Reopened since a few integration tests need to be revisited still... |
Juergen Hoeller commented This is finally in master now. |
Marten Deinum commented I also noticed some changes in regards to the Test Context Framework. Would this then fix #14113 and/or #9309 (which was a proposed solution for #14113) as well?
|
Sam Brannen commented Marten, hold that thought! I promise to get back to you on that. ;-) |
Juergen Hoeller commented As far as I can see right now, this should completely address #14113 indeed, whereas #9309 is somewhat different in its goals. |
Sam Brannen commented I have marked #14113 as resolved for Spring Framework 5.1 RC3 (and reassigned it to Juergen). Whereas, #9309 remains open in the General Backlog for the time being. |
HI I'm also facing this problem. I'm using Java 8. Is there a work-around for this? |
@anirudh-eka, this was fixed in Spring Framework 5.1, 2.5 years ago. If you are encountering a similar problem on a supported version of the Spring Framework, please create a new issue describing the problem. Thanks |
@sbrannen Thank you for your prompt reply! Currently my team is using SpringFramework 5.0. Strangely no other team member except myself is facing the above issue. Do you have any insight as to why this may be? |
@anirudh-eka Hi, have you solved your issue? I'm having it as well, and it also seems like it's something just on my system because my coworker seems to run the same project just fine. At first, I thought it might be an issue with JDKs, so I uninstalled all JDK's on my system and installed Oracle JDK for Java 8. But it did not help. Our projects seem to be similar - java 8, spring 5.0.6 (more precisely springboot 2.0.2). I'm running Fedora 36. |
Ömer Yildiz opened SPR-17137 and commented
Running this Kotlin test in a java 9 or 10 environment throws the following error:
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.Affects: 5.0.5
Issue Links:
@Bean
introspection between@Configuration
classes and 'lite' beans3 votes, 9 watchers
The text was updated successfully, but these errors were encountered: