Skip to content

Commit 4f56296

Browse files
committed
Merge branch 'dev' into timmc/cbor-strict
# Conflicts: # formats/cbor/api/kotlinx-serialization-cbor.klib.api
2 parents d8ddd99 + 1f38e22 commit 4f56296

19 files changed

+201
-168
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ node_modules
2020

2121
# benchmarks.jar
2222
/benchmarks.jar
23+
24+
# Intermediate klibs
25+
.kotlin

CHANGELOG.md

+85
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,88 @@
1+
2+
1.7.0-RC / 2024-05-16
3+
==================
4+
5+
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.
6+
Due to a potential breaking change (see below), it requires a compiler plugin with a version at least of 2.0.0-RC1.
7+
8+
### Important change: priority of PolymorphicSerializer for interfaces during call to serializer<T>() function
9+
10+
Non-sealed interfaces in kotlinx.serialization are always [serializable with a polymorphic serializer](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#serializing-interfaces),
11+
even if they do not have `@Serializable` annotation. This also means that `serializersModule.serializer<SomeInterface>()` call will return you a serializer capable of polymorphism.
12+
This function was written in a way that it unconditionally returns a `PolymorphicSerializer` if type argument is a non-sealed interface.
13+
This caused problems with `SerializersModule` functionality, because actual module was not taken into consideration, and therefore it was impossible
14+
to override serializer for interface using 'contextual serialization' feature. The problem is described in details [here](https://github.com/Kotlin/kotlinx.serialization/issues/2060).
15+
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,
16+
and only if there is no registered contextual serializer for `T`, it returns a polymorphic serializer.
17+
18+
Behavior **before 1.7.0-RC**:
19+
20+
```kotlin
21+
interface SomeInterface
22+
23+
val module = SerializersModule {
24+
contextual(SomeInterface::class, CustomSomeInterfaceSerializer)
25+
}
26+
27+
// Prints PolymorphicSerializer<SomeInterface>:
28+
println(module.serializer<SomeInterface>())
29+
```
30+
31+
Behavior **in 1.7.0-RC, 1.7.0, and higher**:
32+
33+
```kotlin
34+
interface SomeInterface
35+
36+
val module = SerializersModule {
37+
contextual(SomeInterface::class, CustomSomeInterfaceSerializer)
38+
}
39+
40+
// Prints CustomSomeInterfaceSerializer:
41+
println(module.serializer<SomeInterface>())
42+
```
43+
44+
We expect minimal impact from this change but be aware of it anyway.
45+
Implementation details are available in [this PR](https://github.com/Kotlin/kotlinx.serialization/issues/2060).
46+
47+
Due to the [serializer() function being also a compiler intrinsic](https://github.com/Kotlin/kotlinx.serialization/issues/1348), code
48+
of kotlinx.serialization compiler plugin also accommodates for this change in 2.0 branch. To get a consistent result from both plugin and runtime,
49+
kotlinx.serialization compiler plugin should be **at least of 2.0.0-RC1 version.**
50+
**To verify so, 1.7.0-RC runtime will be rejected by older plugins.**
51+
52+
### Json configuration flag to allow commentaries
53+
54+
While JSON standard does not allow any kind of commentaries, they are one of the most popular extensions — for example,
55+
commentaries are widely used in configuration files.
56+
To support this use-case, we added a new configuration flag, `allowComments`.
57+
This flag allows the parser to skip over C/Java-style commentaries in JSON input.
58+
Note that commentaries cannot affect decoding or encoding in any way and are not stored anywhere.
59+
See details in [the PR](https://github.com/Kotlin/kotlinx.serialization/pull/2592).
60+
61+
### Promote `JsonConfiguration.explicitNulls` to a stable API
62+
63+
This configuration flag has been around for a long time and got positive feedback.
64+
Therefore, we are promoting it to a stable state.
65+
It also received functionality enhancements when used with `JsonConfiguration.coerceInputValues` ([#2586](https://github.com/Kotlin/kotlinx.serialization/issues/2586)).
66+
See related [PR](https://github.com/Kotlin/kotlinx.serialization/pull/2661) for details.
67+
68+
### `oneof` support in ProtoBuf
69+
70+
`oneof` fields in protobuf messages [represent a set of optional fields](https://protobuf.dev/programming-guides/proto2/#oneof), where the only one of them is present.
71+
With the help of the new `@ProtoOneOf` annotation, you can naturally map them to Kotlin's sealed class hierarchy.
72+
Check out the comprehensive guide for this feature [here](https://github.com/Kotlin/kotlinx.serialization/blob/194a188563c612c63a88271eb3f28f37353df514/docs/formats.md#oneof-field-experimental).
73+
74+
This functionality was [contributed](https://github.com/Kotlin/kotlinx.serialization/pull/2546) to us by [xzk](https://github.com/xiaozhikang0916).
75+
76+
### Other improvements and bugfixes
77+
78+
* Update okio to 3.9.0 version (#2671)
79+
* Add extension to access original descriptor from one made with SerialDescriptor.nullable (#2633) (thanks to [Chuckame](https://github.com/Chuckame))
80+
* Use @SerialName of inline polymorphic children in Json (#2601) (thanks to [Tad Fisher](https://github.com/tadfisher))
81+
* Fix serializing nulls for a property of a parameterized type with a nullable upper bound with Protobuf (#2561) (thanks to [Shreck Ye](https://github.com/ShreckYe))
82+
* Fixed type discriminator value for custom serializer that uses `encodeJsonElement` (#2628)
83+
* Refine exception messages in case of deserializing data from JsonElement. (#2648)
84+
85+
186
1.6.3 / 2024-02-16
287
==================
388

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
[![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
55
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
66
[![TeamCity build](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/KotlinTools_KotlinxSerialization_Ko.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=KotlinTools_KotlinxSerialization_Ko&guest=1)
7-
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.22-blue.svg?logo=kotlin)](http://kotlinlang.org)
8-
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-serialization-core/1.6.3)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-core/1.6.3)
7+
[![Kotlin](https://img.shields.io/badge/kotlin-2.0.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
8+
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-serialization-core/1.7.0-RC)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-core/1.7.0-RC)
99
[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://kotlinlang.org/api/kotlinx.serialization/)
1010
[![Slack channel](https://img.shields.io/badge/chat-slack-blue.svg?logo=slack)](https://kotlinlang.slack.com/messages/serialization/)
1111

@@ -95,17 +95,17 @@ Kotlin DSL:
9595

9696
```kotlin
9797
plugins {
98-
kotlin("jvm") version "1.9.22" // or kotlin("multiplatform") or any other kotlin plugin
99-
kotlin("plugin.serialization") version "1.9.22"
98+
kotlin("jvm") version "2.0.0-RC3" // or kotlin("multiplatform") or any other kotlin plugin
99+
kotlin("plugin.serialization") version "2.0.0-RC3"
100100
}
101101
```
102102

103103
Groovy DSL:
104104

105105
```gradle
106106
plugins {
107-
id 'org.jetbrains.kotlin.multiplatform' version '1.9.22'
108-
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.22'
107+
id 'org.jetbrains.kotlin.multiplatform' version '2.0.0-RC3'
108+
id 'org.jetbrains.kotlin.plugin.serialization' version '2.0.0-RC3'
109109
}
110110
```
111111

@@ -123,7 +123,7 @@ buildscript {
123123
repositories { mavenCentral() }
124124

125125
dependencies {
126-
val kotlinVersion = "1.9.22"
126+
val kotlinVersion = "2.0.0-RC3"
127127
classpath(kotlin("gradle-plugin", version = kotlinVersion))
128128
classpath(kotlin("serialization", version = kotlinVersion))
129129
}
@@ -134,7 +134,7 @@ Groovy DSL:
134134

135135
```gradle
136136
buildscript {
137-
ext.kotlin_version = '1.9.22'
137+
ext.kotlin_version = '2.0.0-RC3'
138138
repositories { mavenCentral() }
139139
140140
dependencies {
@@ -164,7 +164,7 @@ repositories {
164164
}
165165

166166
dependencies {
167-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
167+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0-RC")
168168
}
169169
```
170170

@@ -176,7 +176,7 @@ repositories {
176176
}
177177
178178
dependencies {
179-
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
179+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0-RC"
180180
}
181181
```
182182

@@ -266,8 +266,8 @@ Ensure the proper version of Kotlin and serialization version:
266266

267267
```xml
268268
<properties>
269-
<kotlin.version>1.9.22</kotlin.version>
270-
<serialization.version>1.6.3</serialization.version>
269+
<kotlin.version>2.0.0-RC3</kotlin.version>
270+
<serialization.version>1.7.0-RC</serialization.version>
271271
</properties>
272272
```
273273

RELEASING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To release new `<version>` of `kotlinx.serialization`:
1313
* [`gradle.properties`](gradle.properties)
1414
* [`integration-test/gradle.properties`](integration-test/gradle.properties)
1515

16-
Update Kotlin version, if necessary.
16+
Update Kotlin version in [`libs.versions.toml`](gradle/libs.versions.toml), if necessary.
1717

1818
5. Write release notes in [`CHANGELOG.md`](CHANGELOG.md):
1919
* Use old releases as example of style.

build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ allprojects {
5555
}
5656
repositories {
5757
mavenCentral()
58+
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
5859
}
5960
}
6061

buildSrc/src/main/kotlin/source-sets-conventions.gradle.kts

-6
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,3 @@ kotlin {
179179
}
180180
}
181181
}
182-
183-
rootProject.extensions.configure<NodeJsRootExtension>() {
184-
// canary nodejs that supports recent Wasm GC changes
185-
nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2"
186-
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
187-
}

0 commit comments

Comments
 (0)