JVM annotations: Java interoperability is one of the advantages of Kotlin. It helped easier transitions to Kotlin while keeping part of your code in Java. There are cases where you would need annotations to tell Kotlin compiler on how the method or field should be used by a Java class.

JVM annotations

Here are some of the commonly used JVM annotations in Kotlin while developing an Android app:

  1. @JvmStatic
  2. @JvmField
  3. @JvmOverloads
  4. @JvmName

Your own libraries, modules or 3rd party code written in Java can smoothly access your Kotlin code with the help of above annotations.



By Vivek

Leave a Reply

Your email address will not be published. Required fields are marked *