I noticed that if I create a class whose primary c...
# announcements
s
I noticed that if I create a class whose primary constructor contains only parameters with default values - an empty constructor is available for Java code to call, without the use of
@JvmOverloads
e.g.
Copy code
class Foo(s: String? = null, i: Int = 3) // `new Foo();` from Java compiles
However, that’s not the case when using a secondary constructor e.g.
Copy code
class Foo {
   constructor(s: String? = null, i: Int = 3) // `new Foo();` from Java does not compiles
}
Is this behavior documented somewhere? I couldn’t find anything..
o
Very interesting. Maybe tag someone from JB for this
v
iirc it is documented
image.png
image.png
s
oh nice! thanks @Vampire! (btw looks like the links moved? I got 404 from your links, but found it in https://kotlinlang.org/docs/reference/classes.html + https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html )
v
Ah, sorry, I'm on the new experimental documentation version
👍 1