I have this kind of implementation but it’s not allowed after bumping Kotlin to 1.6.10 and received the following error which was warning until previous version.
Code:
sealed class PowerTool(
@JvmField open val name: String,
@JvmField open val price: Double
) {
data class CircularSaw(
val diameter: Int,
val cordless: Boolean,
override val name: String,
override val price: Double
) : PowerTool(name, price)
data class DrillPress(
val rpm: Int,
override val name: String,
override val price: Double
) : PowerTool(name, price)
}
Error: JvmField can only be applied to final property
My requirement for jvm field is: I need @JvmField for java consumers as I don’t want to refactor the code to use the setter/getter method and want to use as a field.
Any thoughts?