Evgeniy Zaharov
07/10/2019, 7:11 AMdata class
contains params with inline
classes. For deserialisation I use jackson
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 Outer
class kotlin compile use synthetic method with DefaultConstructorMarker
witch doesn’t contains any additional check for inline params and only calls private constructor after. Why just not make main constructor public
and use it for initialisation?
Simple example for reproduce is below:
inline class InlineValue(val value: String)
data class Outer(
val value: Int,
val inlineValue: InlineValue
)
and in will be compiled to:
public final class Outer {
...
private Outer(int value, String inlineValue) {
this.value = value;
this.inlineValue = inlineValue;
}
...
}
diesieben07
07/10/2019, 7:40 AMinit
blocks, which requires special logic when calling methods/constructors with inline-class parameters.diesieben07
07/10/2019, 7:41 AM@JsonCreator
.diesieben07
07/10/2019, 7:41 AM@JsonValue
in the class you call InlineValue
instead.Evgeniy Zaharov
07/10/2019, 10:21 AMdiesieben07
07/10/2019, 12:32 PM