what's the easiest way of making this interoperabl...
# getting-started
t
what's the easiest way of making this interoperable with java?
class MyClass(val arg1: String, val arg2: String? = null)
(making it generate two constructors)
t
This annotation is not applicable to target 'class'
i need to pull out the constructor and then annotate that?
d
class MyClass @JvmOverloads constructor(...)
No need to pull it out, just need to be a bit more specific
t
:l
thanks!
could not have imagined that being valid syntax
j
why not? 🙂 you want to annotate the constructor so it will create the JVMOverloads for you, which is an operation on the constructor and not on the class
n
it does look a little weird (spelling out
constructor
like that) but it is documented here: • https://kotlinlang.org/docs/reference/annotations.html#usagehttps://kotlinlang.org/docs/reference/classes.html#constructors
👍 1