kotlin gradle plugin 1.8.0 typereference bug
Closed this issue · 10 comments
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
A bug occurs in typereference when running Kotlin plugin version 1.8.0. This phenomenon does not appear when running debug. Please confirm.
bug content
"Internal error: TypeReference constructed without actual type information"
thank you
To Reproduce
// Your code here
Expected behavior
No response
Versions
Kotlin: 1.8.0
Jackson-module-kotlin: 2.13.1
Jackson-databind: 2.13.1
Additional context
No response
Jackson 2.13.1 is not the latest (or close to latest) version. Could you please try with at least 2.15.3, or (ideally) 2.16.0?
Also: how exactly are you triggering the issue? How could this be reproduced?
When updating to 2.15 and 2.16, an Unsupported class file major version 63 error is generated in com.fasterxml.jackson.core\jackson-core\2.16.0, so testing is not possible.
@gudals1947 Huh? Major Version 63 would mean JDK 19 and jackson-core
releases are built with JDK 8 (major version 52). So that does not sound like something that occurs with Jackson artifacts from Maven Central.
I am not sure how you would manage to get that error.
But I hope issue can be reproduced.
@cowtowncoder I am using jdk 19 version in Android Studio. Please check if it is compatible with version 2.16.
@gudals1947 Please go check that yourself. Jackson in general works with JDKs up to and including 21.
At this point there is no information here to know what the problem might be, how to reproduce and so on.
Without such information this issue will be closed soon; leaving here for now to give submitter a chance to add information.
The previous question was my mistake, sorry.
However, after updating to 2.14, the error Internal error: TypeReference constructed without actual type information still appears when building.
Below is a code example.
fun generateMapper(): JsonMapper {
return JsonMapper.builder()
.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.addModule(
KotlinModule.Builder()
.configure(KotlinFeature.NullIsSameAsDefault, enabled = true)
.configure(KotlinFeature.StrictNullChecks, enabled = true)
.build()
)
.addModule(DateTimeFormatModule())
.disable(MapperFeature.AUTO_DETECT_IS_GETTERS)
.build()
}
generateMapper().readValue(
generateMapper().writeValueAsString(response),
object : TypeReference<Map<String, Any>>() {})["message"].toString()
{
"message" : "123"
}
# Jackson
-keep @com.fasterxml.jackson.annotation.JsonIgnoreProperties class * { *; }
-keep class com.fasterxml.** { *; }
-keep class org.codehaus.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepclassmembers public final enum com.fasterxml.jackson.annotation.JsonAutoDetect$Visibility {
public static final com.fasterxml.jackson.annotation.JsonAutoDetect$Visibility *;
}
# General
-keepattributes SourceFile,LineNumberTable,*Annotation*,EnclosingMethod,Signature,Exceptions,InnerClasses
-dontwarn java.beans.ConstructorProperties
-dontwarn java.beans.Transient
-keep class kotlin.Metadata { *; }
-keep class kotlin.reflect.** { *; }
It works well in Android debug, but an error appears in the release version.
Ok. Does the same happen with Jackson 2.15.3 and 2.16.0?
@cowtowncoder
Yes, the same phenomenon is being observed when using 2.16 and 2.15.
It works well in Android debug, but an error appears in the release version.
This means it is not a jackson-module-kotlin
problem.
There are no fixes possible in this repository, so please submit your issue to the appropriate place.
To those who had a hard time finding how to fix it, I added this to my proguard-rules.pro:
-keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; }
-keep class com.fasterxml.jackson.core.type.TypeReference