However, this doesn’t mean we can’t have fields at all, there are certain scenarios, where it’s necessary. In this case, we can leverage the @JvmField annotation, which instructs the compiler not to generate getters and setters for the property and expose it as a simple Java field.

Let’s have a look at the Kotlin example:

class KotlinJvmSample {
@JvmField
val example = "Hello!"
}

And its Java decompiled counterpart – which, indeed, proves that the field was exposed in the standard Java way: