DEV Community

Discussion on: War Stories: The elusive Service

Collapse
 
psfeng profile image
Pin-Sho Feng

I'd also suggest to use that plugin. It doesn't just blindly open all the classes, but only those with certain annotations such as @Service, @Component...

I'd argue it's worse to put open in classes that aren't supposed to be, as those welcome maintainers to potentially subclass them, which could have worse consequences. At the end of the day, the issue here is not Kotlin but Spring doing black magic from behind.

Thread Thread
 
martinhaeusler profile image
Martin Häusler

Oh, I knew about all-open, so now there's another one specific for Spring? Okay, I'll have a second look at it.

Well it's a very unfortunate combination of Kotlin doing its thing, and Spring doing its thing. Plus, Spring should throw an exception if this case is encountered (code simply breaks if it is final, this is not a use case that needs to be preserved). But in general I agree: bytecode generation has a bad smell to it.