Skip to content

Commit b01c4bd

Browse files
committed
Fix the call would fail if callable.isAccessible was false.
1 parent 844ce35 commit b01c4bd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/MethodValueCreator.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ internal class MethodValueCreator<T> private constructor(
2323
// abort, we have some unknown case here
2424
if (!possibleCompanion.isCompanion) return null
2525

26+
val initialCallableAccessible = callable.isAccessible
27+
if (!initialCallableAccessible) callable.isAccessible = true
28+
2629
val (companionObjectInstance: Any, accessible: Boolean) = try {
2730
// throws ex
2831
val instance = possibleCompanion.objectInstance!!
32+
2933
// If an instance of the companion object can be obtained, accessibility depends on the KFunction
30-
instance to callable.isAccessible
34+
instance to initialCallableAccessible
3135
} catch (ex: IllegalAccessException) {
3236
// fallback for when an odd access exception happens through Kotlin reflection
3337
possibleCompanion.java.enclosingClass.fields

0 commit comments

Comments
 (0)