In Kotlin, classes and members are final by default . In other words, the following declarations have the same bytecode:
@JvmField final val CREATOR: Parcelable.Creator<Person> = PersonCreator() @JvmField val CREATOR: Parcelable.Creator<Person> = PersonCreator()
Thus, although the generated code has the final keyword, and this is not an error, it is redundant.
Although classes and members are final by default, there is still a need for a final modifier in Kotlin. One example would be to mark the open method as final in a derived class:
open class Base { open fun test(){} } open class DerivedA : Base(){ final override fun test(){} } class DerivedB : DerivedA() { override fun test(){}
While itβs good practice to make the public static final field in java there is no strict requirement for the Parccelable.Creator field Parccelable.Creator marked as such:
Classes that implement the Parcelable interface must also have a non-empty static field called a type CREATOR that implements the Parcelable.Creator Interface.
source share