FasterXML / jackson-module-kotlin

Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Apache License 2.0
1.11k stars 175 forks source link

Fix #807 by enabling `MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS` on selected tests #811

Closed cowtowncoder closed 1 month ago

cowtowncoder commented 1 month ago

@k163377 @JooHyukKim here are changes to work around the issues. But tests suggest that there are many cases where forcing setting of final Fields is expected for Kotlin usage. Ideally this should not be required as JVM may well stop allowing this to be done; plus, usually value should be passed through constructor anyway. Unfortunately I wasn't able to really properly fix any of failing tests in that regard.

JooHyukKim commented 1 month ago

Unfortunately I wasn't able to really properly fix any of failing tests in that regard.

Yeah the handling of final fields seems to be required of Kotlin module at the moment. I also failed to come up with module-level solution that we can integrate into pre-Jackson 3.

This issue may be a blocker problem- Jackson 3 🤔

cowtowncoder commented 1 month ago

@JooHyukKim it is a concern yes. But I think we are ok for now -- change in defaults is not causing an issue as much as exposing it, I think (one really should not modify final field values).