I am testing a new kotlin-allopen and kotlin-spring plugins under Kotlin 1.0.6.
In one of my @Transactional-annotated classes I have a field:
@JvmField val foo = null
When I try to build the project, I get:
Error:(45, 5) Kotlin: JvmField can only be applied to final property
Is there any proper way of dealing with this? My real-life code needed @JvmField because of the JUnit's @Rule. Managed to "solve" the problem by removing a @JvmField and annotating a getter instead. Not sure if a bug or a feature.
I got the official solution.
In such case, finality provided by val is not enough. It turns out you need explicitly add final keyword there and this is not considered a bug.
@JvmField final val foo = null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With