Hi. I have a problem with deserialising `data clas...
# announcements
Hi. I have a problem with deserialising
data class
contains params with
classes. For deserialisation I use
and it fail with it. But then I try to discover a problem I found that this
data class
compile to class with private main constructor. Is it expected behaviour or bug (for me at lease, and feature for others)? It seems not right solutions for it, because for initialisation of
class kotlin compile use synthetic method with
witch doesn’t contains any additional check for inline params and only calls private constructor after. Why just not make main constructor
and use it for initialisation? Simple example for reproduce is below:
Copy code
inline class InlineValue(val value: String)

data class Outer(
    val value: Int,
    val inlineValue: InlineValue
and in will be compiled to:
Copy code
public final class Outer {
   private Outer(int value, String inlineValue) {
      this.value = value;
      this.inlineValue = inlineValue;
The reason is to specifically disallow the calling of the constructor (from e.g. Java) and just passing the underlying type of the inline class. In the future inline classes will have
blocks, which requires special logic when calling methods/constructors with inline-class parameters.
If you want to allow creation of the class with just the underlying value you should provide a separate factory method (or constructor). You can then mark that for Jackson to use using
Otherwise if you are just "abusing" inline classes to get a particular JSON representation you should use things like
in the class you call
But in Java you could call synthetic method, and as I suppose they also be public in future. Why just not to add checks for inline parameters to data class constructor, and leave a constructor public?
You can't call a synthetic method from Java.