Interoperability between Java and Kotlin is very strong by default. However, there are a number of options available to us so that we can improve how we can use Kotlin from Java. We can use the @JvmName annotation to control the name Java classes that are generated from our Kotlin code. By using the @JvmOverloads annotation, we can generate method overloads to help us take advantage of default parameter values that are not supported in Java. While Kotlin does not have a static keyword, we can use the @JvmStatic annotation to mark properties and methods of companion objects. By doing this, the compiler will generate true JVM static methods for accessing these properties and methods with a syntax that feels much more natural from Java.
We also saw how we can provide alternative names for our companion objects to improve the call-site syntax in Java and to provide increased semantic meaning to our code.
Lastly, we saw how we can specify use-site targets for our annotations so that we have greater control over how the Kotlin compiler annotates generated Java elements. These tools allow us to write Kotlin code that can be used from Java in a manner that feels very natural.
In the next chapter, we'll explore how to start introducing Kotlin through testing.