Skip to content
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

Bump org.jetbrains.kotlinx:kotlinx-serialization-json from 1.4.0-RC to 1.7.0-RC #62

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github May 17, 2024

Bumps org.jetbrains.kotlinx:kotlinx-serialization-json from 1.4.0-RC to 1.7.0-RC.

Release notes

Sourced from org.jetbrains.kotlinx:kotlinx-serialization-json's releases.

1.7.0-RC

This is a release candidate for the next version. It is based on Kotlin 2.0.0-RC3 and is fully compatible with a stable Kotlin 2.0 release. Due to a potential breaking change (see below), it requires a compiler plugin with a version at least of 2.0.0-RC1.

Important change: priority of PolymorphicSerializer for interfaces during call to serializer() function

Non-sealed interfaces in kotlinx.serialization are always serializable with a polymorphic serializer, even if they do not have @Serializable annotation. This also means that serializersModule.serializer<SomeInterface>() call will return you a serializer capable of polymorphism. This function was written in a way that it unconditionally returns a PolymorphicSerializer if type argument is a non-sealed interface. This caused problems with SerializersModule functionality, because actual module was not taken into consideration, and therefore it was impossible to override serializer for interface using 'contextual serialization' feature. The problem is described in detail here. To overcome these problems, we had to change the behavior of this function regarding interfaces. It now looks into SerializersModule first if T is a non-sealed interface, and only if there is no registered contextual serializer for T, it returns a polymorphic serializer.

Behavior before 1.7.0-RC:

interface SomeInterface
val module = SerializersModule {
contextual(SomeInterface::class, CustomSomeInterfaceSerializer)
}
// Prints PolymorphicSerializer<SomeInterface>:
println(module.serializer<SomeInterface>())

Behavior in 1.7.0-RC, 1.7.0, and higher:

interface SomeInterface
val module = SerializersModule {
contextual(SomeInterface::class, CustomSomeInterfaceSerializer)
}
// Prints CustomSomeInterfaceSerializer:
println(module.serializer<SomeInterface>())

We expect minimal impact from this change, but be aware of it anyway. Implementation details are available in this PR.

Due to the serializer() function being also a compiler intrinsic, code of kotlinx.serialization compiler plugin also accommodates this change in the 2.0 branch. To get a consistent result from both plugin and runtime, kotlinx.serialization compiler plugin should be at least of 2.0.0-RC1 version. To verify so, 1.7.0-RC runtime will be rejected by older plugins.

Json configuration flag to allow commentaries

While JSON standard does not allow any kind of commentaries, they are one of the most popular extensions — for example, commentaries are widely used in configuration files. To support this use-case, we added a new configuration flag, allowComments. This flag allows the parser to skip over C/Java-style commentaries in JSON input. Note that commentaries cannot affect decoding or encoding in any way and are not stored anywhere. See details in the PR.

Promote JsonConfiguration.explicitNulls to a stable API

This configuration flag has been around for a long time and got positive feedback. Therefore, we are promoting it to a stable state. It also received functionality enhancements when used with JsonConfiguration.coerceInputValues ([#2586 (https://redirect.github.com/Kotlin/kotlinx.serialization/issues/2586)). See related PR for details.

... (truncated)

Changelog

Sourced from org.jetbrains.kotlinx:kotlinx-serialization-json's changelog.

1.7.0-RC / 2024-05-16

This is a release candidate for the next version. It is based on Kotlin 2.0.0-RC3 and is fully compatible with a stable Kotlin 2.0 release. Due to a potential breaking change (see below), it requires a compiler plugin with a version at least of 2.0.0-RC1.

Important change: priority of PolymorphicSerializer for interfaces during call to serializer() function

Non-sealed interfaces in kotlinx.serialization are always serializable with a polymorphic serializer, even if they do not have @Serializable annotation. This also means that serializersModule.serializer<SomeInterface>() call will return you a serializer capable of polymorphism. This function was written in a way that it unconditionally returns a PolymorphicSerializer if type argument is a non-sealed interface. This caused problems with SerializersModule functionality, because actual module was not taken into consideration, and therefore it was impossible to override serializer for interface using 'contextual serialization' feature. The problem is described in details here. To overcome these problems, we had to change the behavior of this function regarding interfaces. It now looks into SerializersModule first if T is a non-sealed interface, and only if there is no registered contextual serializer for T, it returns a polymorphic serializer.

Behavior before 1.7.0-RC:

interface SomeInterface
val module = SerializersModule {
contextual(SomeInterface::class, CustomSomeInterfaceSerializer)
}
// Prints PolymorphicSerializer<SomeInterface>:
println(module.serializer<SomeInterface>())

Behavior in 1.7.0-RC, 1.7.0, and higher:

interface SomeInterface
val module = SerializersModule {
contextual(SomeInterface::class, CustomSomeInterfaceSerializer)
}
// Prints CustomSomeInterfaceSerializer:
println(module.serializer<SomeInterface>())

We expect minimal impact from this change but be aware of it anyway. Implementation details are available in this PR.

Due to the serializer() function being also a compiler intrinsic, code of kotlinx.serialization compiler plugin also accommodates for this change in 2.0 branch. To get a consistent result from both plugin and runtime, kotlinx.serialization compiler plugin should be at least of 2.0.0-RC1 version. To verify so, 1.7.0-RC runtime will be rejected by older plugins.

... (truncated)

Commits
  • dd1b76e Prepare Changelog and Readme for 1.7.0-RC release
  • b4bf182 Raise Require-Kotlin-Version to 2.0.0-RC1
  • 022ba26 Update to Kotlin 2.0.0-RC3
  • 53b2916 Merge remote-tracking branch 'origin/master' into dev
  • 194a188 Stabilize explicitNulls feature (#2661)
  • 53fdc53 Fix confusing description of JsonPrimitive.content (#2670)
  • e35c28d Refine exception messages in case of deserializing data from JsonElement. (#2...
  • b1dd800 Specify time zone in example code to fix test instability across locales (#2664)
  • d5a4d30 Update okio to 3.9.0 version (#2671)
  • 5aa1032 Migrated build scripts to kts (#2654)
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot requested a review from a team as a code owner May 17, 2024 05:44
@dependabot dependabot bot added dependencies Pull requests that update a dependency file java Pull requests that update Java code labels May 17, 2024
Bumps [org.jetbrains.kotlinx:kotlinx-serialization-json](https://github.com/Kotlin/kotlinx.serialization) from 1.4.0-RC to 1.7.0-RC.
- [Release notes](https://github.com/Kotlin/kotlinx.serialization/releases)
- [Changelog](https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md)
- [Commits](Kotlin/kotlinx.serialization@v1.4.0-RC...v1.7.0-RC)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlinx:kotlinx-serialization-json
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot force-pushed the dependabot/maven/org.jetbrains.kotlinx-kotlinx-serialization-json-1.7.0-RC branch from 08da888 to 7050e73 Compare May 31, 2024 10:05
@LudvigHz LudvigHz merged commit d75dcd0 into main May 31, 2024
1 check passed
@LudvigHz LudvigHz deleted the dependabot/maven/org.jetbrains.kotlinx-kotlinx-serialization-json-1.7.0-RC branch May 31, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file java Pull requests that update Java code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant