|
| 1 | +1.8.0-RC / 2024-13-10 |
| 2 | +================== |
| 3 | + |
| 4 | +This is a release candidate for the next version. It is based on Kotlin 2.1.0 and includes a few new features, as well |
| 5 | +as bugfixes and improvements: |
| 6 | + |
| 7 | +## `@JsonIgnoreUnknownKeys` annotation |
| 8 | + |
| 9 | +Previously, only global setting `JsonBuilder.ignoreUnknownKeys` controlled whether Json parser would throw exception if |
| 10 | +input contained a property that was not declared in a `@Serializable` class. |
| 11 | +There were [a lot of complaints](https://github.com/Kotlin/kotlinx.serialization/issues/1420) that this setting is not |
| 12 | +flexible enough. |
| 13 | +To address them, we added new `@JsonIgnoreUnknownKeys` annotation that can be applied on a per-class basis. |
| 14 | +With this annotation, it is possible to allow unknown properties for annotated classes, while |
| 15 | +general decoding methods (such as `Json.decodeFromString` and others) would still reject them for everything else. |
| 16 | +See details in the corresponding [PR](https://github.com/Kotlin/kotlinx.serialization/pull/2874). |
| 17 | + |
| 18 | +## Stabilization of `SerialDescriptor` API and `@SealedSerializationApi` annotation |
| 19 | + |
| 20 | +`SerialDescriptor`, `SerialKind`, and related API has been around for a long time and has proven itself useful. |
| 21 | +The main reason `@ExperimentalSerializationApi` was on SerialDescriptor's properties is that we wanted to discourage |
| 22 | +people from subclassing it. |
| 23 | +Fortunately, Kotlin 2.1 provides a special mechanism for such a |
| 24 | +case — [SubclassOptInRequired](https://kotlinlang.org/docs/opt-in-requirements.html#opt-in-to-inherit-from-a-class-or-interface). |
| 25 | +New `kotlinx.serialization.SealedSerializationApi` annotation designates APIs |
| 26 | +as public for use, but closed for implementation — the case for SerialDescriptor, which is a non-sealed interface for |
| 27 | +technical reasons. |
| 28 | +Now you can use most of `SerialDescriptor` and its builders API without the need to opt-in into experimental |
| 29 | +serialization API. |
| 30 | +See the [PR](https://github.com/Kotlin/kotlinx.serialization/pull/2827) for more details. |
| 31 | + |
| 32 | +_Note_: All `SerialKind`s are stable API now, except `PolymorphicKind` — we may want to expand it in the future. |
| 33 | + |
| 34 | +## Generate Java 8's default method implementations in interfaces |
| 35 | + |
| 36 | +**TL;DR This change ensures better binary compatibility in the future for library. You should not experience any |
| 37 | +difference from it.** |
| 38 | + |
| 39 | +kotlinx.serialization library contains a lot of interfaces with default method implementations. Historically, Kotlin |
| 40 | +compiled a synthetic `DefaultImpls` class for them. |
| 41 | +[Starting from Kotlin 1.4](https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/), |
| 42 | +it was possible to compile them using as Java 8's `default` methods to ensure |
| 43 | +that new methods can still be added to interfaces without the need for implementors to recompile. |
| 44 | +To preserve binary compatibility with existing clients, a special `all-compatbility` mode is supported in compiler |
| 45 | +to generate both `default` methods and synthetic `DefaultImpls` class. |
| 46 | + |
| 47 | +Now, kotlinx.serialization finally makes use of this `all-compatibility` mode, |
| 48 | +which potentially allows us to add new methods to interfaces such as `SerialDescriptor`, `Encoder`, `Decoder`, etc., |
| 49 | +without breaking existing clients. This change is expected to have no effect on existing clients, and no action from |
| 50 | +your side is required. |
| 51 | +Note that Kotlin 2.2 plans to enable `all-compatibility` |
| 52 | +mode [by default](https://youtrack.jetbrains.com/issue/KTLC-269). |
| 53 | + |
| 54 | +## Other bugfixes and improvements |
| 55 | + |
| 56 | +* Correctly skip structures with Cbor.ignoreUnknownKeys setting (#2873) |
| 57 | +* Handle missing system property without NPE (#2867) |
| 58 | +* Fixed keeping INSTANCE field and serializer function for serializable objects in R8 full mode (#2865) |
| 59 | +* Correctly parse invalid numbers in JsonLiteral.long and other extensions (#2852) |
| 60 | +* Correctly handle serial name conflict for different classes in SerializersModule.overwriteWith (#2856) |
| 61 | +* Add inline reified version of encodeToString as a Json member to streamline the experience for newcomers. (#2853) |
| 62 | +* Do not check kind or discriminator collisions for subclasses' polymorphic serializers if Json.classDiscriminatorMode |
| 63 | + is set to NONE (#2833) |
| 64 | + |
1 | 65 | 1.7.3 / 2024-09-19
|
2 | 66 | ==================
|
3 | 67 |
|
|
0 commit comments