Why is the generated json adapter using reflection...
# squarelibraries
p
Why is the generated json adapter using reflection for classes with default parameters? I have crashes at runtime because the codegen is apparently using reflection now and proguard stripped it.
🤔 1
b
If I remember correctly from my investigation into inline classes, the code gen version uses reflection to call a synthetic function that kotlin generates for functions with default parameters. This is the only way to call the constructor with kotlin filling in the default arguments. The old system used to call the constructor with the minimal arguments allowed (everything default) and than used
copy
to fill in the rest. That way you can get the default arguments without using the synthetic method, but it copies all the data twice. Not sure this is the better solution, but I think those are the only 2 options. Neither is perfect. Also I have no idea why this was changed. Maybe because the old solution only worked for data classes since it relied on the copy method.
p
f
@Paul Woitaschek it was always using reflection by default...
p
@florent nope
That's the point of the codegen
f
sorry I miss read the issue, I wanted to say that generateAdapter is false by default and using reflection by default