Skip to content

Value class with invoke operator and private constructor fail in 2.20 #1050

@xRomZak

Description

@xRomZak

Search before asking

  • I searched in the issues and found nothing similar.
  • I have confirmed that the same problem is not reproduced if I exclude the KotlinModule.
  • I searched in the issues of databind and other modules used and found nothing similar.
  • I have confirmed that the problem does not reproduce in Java and only occurs when using Kotlin and KotlinModule.

Describe the bug

After upgrade 2.19.* -> 2.20.0 deserialization doesn't work, when an object references a value class with private constructor ad custom operator invoke.

java.lang.IllegalAccessException: member is private: mdm.model.PortCode.constructor-impl[Ljava.lang.Object;@4e6920e/invokeStatic, from class com.fasterxml.jackson.module.kotlin.InternalCommonsKt (unnamed module @38363e96)
	at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:894)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:3987)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkMethod(MethodHandles.java:3923)
	at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:4072)
	at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(MethodHandles.java:4065)
	at java.base/java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:3451)
	at com.fasterxml.jackson.module.kotlin.InternalCommonsKt.unreflect(InternalCommons.kt:64)
	at com.fasterxml.jackson.module.kotlin.NoConversionCreatorBoxDeserializer.<init>(KotlinDeserializers.kt:112)

Example of value class (work in 2.19).

@JvmInline
value class PortCode private constructor(val value: String) : Comparable<PortCode> {

  companion object {
    operator fun invoke(value: String) = PortCode(value.uppercase(Locale.getDefault()))
  }
}

To Reproduce

// Your code here

Expected behavior

No response

Versions

Kotlin:
Jackson-module-kotlin:
Jackson-databind:

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions