-
-
Notifications
You must be signed in to change notification settings - Fork 180
Fixed a bug in #512. #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed a bug in #512. #533
Changes from 4 commits
844ce35
b01c4bd
c0a58ab
3428cd3
5eca9cd
b19c44f
c9df362
9aa88e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,18 @@ internal class MethodValueCreator<T> private constructor( | |
// abort, we have some unknown case here | ||
if (!possibleCompanion.isCompanion) return null | ||
|
||
val initialCallableAccessible = callable.isAccessible | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good name 👍 |
||
if (!initialCallableAccessible) callable.isAccessible = true | ||
|
||
val (companionObjectInstance: Any, accessible: Boolean) = try { | ||
// throws ex | ||
val instance = possibleCompanion.objectInstance!! | ||
|
||
// If an instance of the companion object can be obtained, accessibility depends on the KFunction | ||
instance to callable.isAccessible | ||
instance to initialCallableAccessible | ||
} catch (ex: IllegalAccessException) { | ||
// fallback for when an odd access exception happens through Kotlin reflection | ||
possibleCompanion.java.enclosingClass.fields | ||
possibleCompanion.java.enclosingClass.declaredFields | ||
.firstOrNull { it.type.kotlin.isCompanion } | ||
?.let { | ||
it.isAccessible = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,8 +199,8 @@ class TestJacksonWithKotlin { | |
|
||
private class StateObjectWithFactoryOnNamedCompanion private constructor (override val name: String, override val age: Int, override val primaryAddress: String, override val wrongName: Boolean, override val createdDt: Date) : TestFields { | ||
var factoryUsed: Boolean = false | ||
companion object Named { | ||
@JvmStatic @JsonCreator fun create(@JsonProperty("name") nameThing: String, @JsonProperty("age") age: Int, @JsonProperty("primaryAddress") primaryAddress: String, @JsonProperty("renamed") wrongName: Boolean, @JsonProperty("createdDt") createdDt: Date): StateObjectWithFactoryOnNamedCompanion { | ||
private companion object Named { | ||
@JvmStatic @JsonCreator private fun create(@JsonProperty("name") nameThing: String, @JsonProperty("age") age: Int, @JsonProperty("primaryAddress") primaryAddress: String, @JsonProperty("renamed") wrongName: Boolean, @JsonProperty("createdDt") createdDt: Date): StateObjectWithFactoryOnNamedCompanion { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All lines that were exceeding 120 characters in length depending on the parameter were modified to break lines. |
||
val obj = StateObjectWithFactoryOnNamedCompanion(nameThing, age, primaryAddress, wrongName, createdDt) | ||
obj.factoryUsed = true | ||
return obj | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you add a note here or in the class comment as to why
isAccessible
is being forced to true?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
5eca9cd