![]() ![]() Adding the annotation does not always make your API easily accessible to Java, in those situations, it is on you to put the work in and craft a well thought out API. A record class declaration consists of a name optional type parameters (generic record declarations are supported) a header, which lists the 'components' of the record and a body. It does so by generating additional overloads and placing them in the bytecode that Java interacts with. SummaryĪdding the annotation to your functions and constructors persuades them to play nicer with Java. Java, on the other hand, requires you to apply some of your brainpower to write functions that are friendly to use. When creating a public API as part of a library, especially when you want it to play well with Java, spending time considering how your functions will be leveraged will make everyone happier.ĭevelopers consuming a Kotlin API when using the language themselves can use its features to get around potential problems in your code. The main piece of advice I want to give you here is to really think about the functions you create. Some examples should help grasp this definition.īelow are the different ways to call the doStuff function from earlier in Java:Ĭlass MyJvmOverloadsClass constructor ( private val a : String = "Default value", private val b : Int = 1, private val c : Boolean = false )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |