Question regarding Kotlin Properties

31 views
Skip to first unread message

tamirda

unread,
Apr 17, 2023, 1:30:06 AM4/17/23
to jackson-user
Hello!
I have a question regarding naming conventions in Kotlin and how jackson-databind handles them.
According to https://kotlinlang.org/docs/java-to-kotlin-interop.html#properties , Kotlin automatically creates getter and setters with the names "get"/"set" + PropertyName.

However, for security purposes, I want to use ProGuard, which will rename these getters/setters into mangled name.

This raises an issue with the package, as the package tries to locate getters/setters by appending "get"/"set" to the property name.
This eventually causes a crash/null assignment/unexpected behavior of the app.

However, I saw that FasterXML has a "fallback" to look for properties in the Kotlin Metadata when it doesn't find a JsonAnnotation:

Kotlin Metadata also includes the signatures of the getters and setters of the class' fields.

Unfortunately, BeanSerializer doesn't use this fallback and do not initialize the value (since the getter/setter is proguarded)

Is there a way to make it look in the Kotlin Metadata instead of appending "get"/"set" to the property name?

Thank you very much!

Reply all
Reply to author
Forward
0 new messages