FasterXML / FasterXML/jackson-module-kotlin

Make it possible to get information about creator functions from `KotlinInvalidNullException`

Open
#1,026 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
1.2k
Forks
187
Avg merge
9h 48m
Merged PRs (30d)
16

Description

This issue is a discussion of features after merging of foo and after #1025.
wrt: https://github.com/FasterXML/jackson-module-kotlin/issues/617#issuecomment-3124423585

---

Unlike the deprecated `MissingKotlinParameterException`, `KotlinInvalidNullException` has no information about the creator function.
This is because it was very difficult to keep reflection-related information while keeping the class as `Serializable`.

It is not impossible to include creator function information in a new exception, provided that the process is allowed to become very complex.

Personally, I can think of a way to keep the creator function as a string in the form of `JvmSignature` and restore it during processing if necessary.
[A similar process has been implemented in `Kogera`](https://github.com/ProjectMapK/jackson-module-kogera/blob/cec770386ef1eb6759b4320ed67316617e7e0313/src/main/kotlin/io/github/projectmapk/jackson/module/kogera/InternalCommons.kt#L120-L128).
This would allow the new exception to act as if it were holding a `KFunction` or `KParameter`.

However, this has the following problems

- It requires a lot of additional code and tests for the encoding/decoding process to the `JvmSignature` format.
- Many edge cases must be considered, especially when `value class` is involved.
- When new features such as `multi-field value class` become available, more effort is required to support them(#714).
- Factory function definition support without `JvmStatic`(#355) will be difficult.

Personally, I think that there is no need for a function that reads function information directly from exceptions.
This is because the basic information is already included and humans can adequately analyze it from that information.
At least in this case, I feel that the code would be too complicated for the benefit gained.
However, if there is a very strong demand for such a function, I will consider adding it.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.