Skip to content

Commit 4f9b1b4

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.19' into 3.x
2 parents c69f42c + 76a9860 commit 4f9b1b4

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
lines changed

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Contributors:
1818
# 2.19.0 (not yet released)
1919

2020
WrongWrong (@k163377)
21+
* #944: Fixed to use common util for Member accessibility override
2122
* #937: Added type match check to read functions
2223

2324
Tatu Saloranta (@cowtowncoder)

release-notes/VERSION-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Co-maintainers:
1818

1919
2.19.0 (not yet released)
2020

21+
#944: Common util is now used for member accessibility overrides.
2122
#937: For `readValue` and other shorthands for `ObjectMapper` deserialization methods,
2223
type consistency checks have been added.
2324
A `RuntimeJsonMappingException` will be thrown in case of inconsistency.

src/main/kotlin/tools/jackson/module/kotlin/Converters.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import tools.jackson.databind.JavaType
44
import tools.jackson.databind.deser.std.StdConvertingDeserializer
55
import tools.jackson.databind.ser.std.StdDelegatingSerializer
66
import tools.jackson.databind.type.TypeFactory
7+
import tools.jackson.databind.util.ClassUtil
78
import tools.jackson.databind.util.StdConverter
89
import kotlin.reflect.KClass
910
import kotlin.time.toJavaDuration
@@ -51,7 +52,7 @@ internal class ValueClassBoxConverter<S : Any?, D : Any>(
5152
val boxedClass: KClass<D>
5253
) : StdConverter<S, D>() {
5354
private val boxMethod = boxedClass.java.getDeclaredMethod("box-impl", unboxedClass).apply {
54-
if (!this.isAccessible) this.isAccessible = true
55+
ClassUtil.checkAndFixAccess(this, false)
5556
}
5657

5758
@Suppress("UNCHECKED_CAST")

src/main/kotlin/tools/jackson/module/kotlin/KotlinDeserializers.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import tools.jackson.databind.ValueDeserializer
1111
import tools.jackson.databind.deser.Deserializers
1212
import tools.jackson.databind.deser.std.StdDeserializer
1313
import tools.jackson.databind.exc.InvalidDefinitionException
14+
import tools.jackson.databind.util.ClassUtil
1415
import java.lang.reflect.Method
1516
import java.lang.reflect.Modifier
1617
import kotlin.reflect.full.primaryConstructor
@@ -94,7 +95,7 @@ internal class WrapsNullableValueClassBoxDeserializer<S, D : Any>(
9495
private val inputType: Class<*> = creator.parameterTypes[0]
9596

9697
init {
97-
creator.apply { if (!this.isAccessible) this.isAccessible = true }
98+
ClassUtil.checkAndFixAccess(creator, false)
9899
}
99100

100101
// Cache the result of wrapping null, since the result is always expected to be the same.

src/main/kotlin/tools/jackson/module/kotlin/KotlinKeyDeserializers.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tools.jackson.databind.*
66
import tools.jackson.databind.deser.jdk.JDKKeyDeserializer
77
import tools.jackson.databind.deser.jdk.JDKKeyDeserializers
88
import tools.jackson.databind.exc.InvalidDefinitionException
9+
import tools.jackson.databind.util.ClassUtil
910
import java.lang.reflect.Method
1011
import kotlin.reflect.KClass
1112
import kotlin.reflect.full.primaryConstructor
@@ -70,7 +71,7 @@ internal class ValueClassKeyDeserializer<S, D : Any>(
7071
private val unboxedClass: Class<*> = creator.parameterTypes[0]
7172

7273
init {
73-
creator.apply { if (!this.isAccessible) this.isAccessible = true }
74+
ClassUtil.checkAndFixAccess(creator, false)
7475
}
7576

7677
// Based on databind error

src/main/kotlin/tools/jackson/module/kotlin/MethodValueCreator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package tools.jackson.module.kotlin
22

3+
import tools.jackson.databind.util.ClassUtil
34
import kotlin.reflect.KFunction
45
import kotlin.reflect.full.extensionReceiverParameter
56
import kotlin.reflect.full.instanceParameter
@@ -39,7 +40,7 @@ internal class MethodValueCreator<T> private constructor(
3940
possibleCompanion.java.enclosingClass.declaredFields
4041
.firstOrNull { it.type.kotlin.isCompanion }
4142
?.let {
42-
it.isAccessible = true
43+
ClassUtil.checkAndFixAccess(it, false)
4344

4445
// If the instance of the companion object cannot be obtained, accessibility will always be false
4546
it.get(null) to false

0 commit comments

Comments
 (0)