Binary compatibility for constructors with default values

Hi.

When I add a new property Y with a default value to data class D that previously only had property X i would expect that previously compiled code P that depended on constructor D(X) would not be affected. This does not seem to be the case.

When I load the updated library containing D and the unchanged library containing P the code in P that is instantiating D fails with something akin to
NoSuchMethodError: D.<init>(X;DefaultConstructorMarker)

If I recompile P it starts to work again.
I tried to make the change to D binary backwards compatible by adding the @JvmOverloads annotation to the constructor but that does not help since the signature of the primary constructor changes.

Is this to be expected? Are there any reasonable workarounds I can use to avoid having to recompile all libraries that depends on D?

4 Likes