-
-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Describe the bug
In Kotlin 1.5.x
, access to private JvmStatic
functions via Java
reflection is broken.
https://youtrack.jetbrains.com/issue/KT-46181
This causes problems with code like the following, where the JsonCreator
is ignored and the primary constructor is called, or when the constructor call is disabled, there is no function to call and instantiation fails.
class Foo private constructor(val foo: Int, val bar: Int) {
companion object {
@JvmStatic
@JsonCreator
private fun creator(foo: Int, bar: Int) = Foo(foo, bar)
}
}
Note that if you run it with Intellij
, the Kotlin
version of the IDE
side will take precedence and this issue may not occur.
#533, It was able to reproduce the problem by running the test with mvn verify
.
To Reproduce
#533
Additional context
If this problem occurs and library versions cannot be changed, there seems to be no workaround other than setting the factory function to public
.
The Since jackson-module-kotlin 2.14
solves this problem because the Kotlin
version is 1.6.x
.jackson-module-kotlin
still uses Kotlin 1.5
in 2.15, this problem may continue to occur.
We may also add tests in jackson-module-kotlin 2.13
that will run on non-Kotlin 1.5.x
(in environments like Intellij
).
(However, we consider the implementation of this test to be low priority. PRs are welcome to add this test.)