Skip to content

Commit fc9343f

Browse files
Update Kotlin and add changelog for 1.2.0 (#1436)
Make guide and reference easier to find Add MOAR badges Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
1 parent 75566cc commit fc9343f

File tree

7 files changed

+111
-44
lines changed

7 files changed

+111
-44
lines changed

CHANGELOG.md

Lines changed: 88 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1+
1.2.0 / 2021-04-27
2+
==================
3+
4+
This release contains a lot of new features and important improvements listed below;
5+
Kotlin 1.5.0 is used as a default compiler and language version.
6+
7+
### JSON performance improvements
8+
9+
JSON encoder and decoder were revisited and significantly rewritten,
10+
which lead us to up to 2-3x times speedup in certain cases.
11+
Additional details can be found in the corresponding issues: [[1]](https://github.com/Kotlin/kotlinx.serialization/pull/1343), [[2]](https://github.com/Kotlin/kotlinx.serialization/pull/1354).
12+
13+
### Ability to specify alternative names during JSON decoding
14+
15+
[The one of the most voted issues](https://github.com/Kotlin/kotlinx.serialization/issues/203) is fixed now — it is possible to specify multiple names for one property
16+
using new `@JsonNames` annotation.
17+
Unlike `@SerialName`, it only affects JSON decoding, so it is useful when dealing with different versions of the API.
18+
We've prepared a [documentation](https://github.com/Kotlin/kotlinx.serialization/blob/dev/docs/json.md#alternative-json-names) for you about it.
19+
20+
### JsonConfiguration in public API
21+
22+
`JsonConfiguration` is exposed as a property of `Json` instance. You can use it to adjust behavior in
23+
your [custom serializers](https://github.com/Kotlin/kotlinx.serialization/blob/dev/docs/json.md#maintaining-custom-json-attributes).
24+
Check out more in the corresponding [issue](https://github.com/Kotlin/kotlinx.serialization/issues/1361) and the [PR](https://github.com/Kotlin/kotlinx.serialization/pull/1409).
25+
26+
### Generator for .proto files based on serializable Kotlin classes
27+
28+
Our implementation of Protocol Buffers format uses `@Serializable` Kotlin classes as a source of schema.
29+
This is very convenient for Kotlin-to-Kotlin communication, but makes interoperability between languages complicated.
30+
To resolve this [issue](https://github.com/Kotlin/kotlinx.serialization/issues/34), we now have a
31+
schema generator that can produce .proto files out of Kotlin classes. Using it, you can keep Kotlin
32+
classes as a source of truth and use traditional protoc compilers for other languages at the same time.
33+
To learn more, check out the documentation for the new `ProtoBufSchemaGenerator` class or
34+
visit the [corresponding PR](https://github.com/Kotlin/kotlinx.serialization/pull/1255).
35+
36+
>Note: this generator is on its experimental stage and any feedback is very welcomed.
37+
38+
### Contextual serialization of generic classes
39+
40+
Before 1.2.0, it was [impossible](https://github.com/Kotlin/kotlinx.serialization/issues/1407) to register context serializer for generic class,
41+
because `contextual` function accepted a single serializer.
42+
Now it is possible to register a provider — lambda that allows to construct a serializer for generic class
43+
out of its type arguments serializers. See the details in the [documentation](https://github.com/Kotlin/kotlinx.serialization/blob/dev/docs/serializers.md#contextual-serialization-and-generic-classes).
44+
45+
### Other features
46+
47+
* Support for watchosX64 target (#1366).
48+
* Introduce kotlinx-serialization-bom (#1356).
49+
* Support serializer<T> on JS IR when T is an interface (#1431).
50+
51+
### Bugfixes
52+
53+
* Fix serializer lookup by KType for third party classes (#1397) (thanks to [mvdbos](https://github.com/mvdbos)).
54+
* Fix inability to encode/decode inline class with string to JsonElement (#1408).
55+
* Throw SerializationException instead of AIOB in ProtoBuf (#1373).
56+
* Fix numeric overflow in JsonLexer (#1367) (thanks to [EdwarDDay](https://github.com/EdwarDDay)).
57+
158

259
1.1.0 / 2021-02-17
360
==================
@@ -12,19 +69,19 @@ We suggest you to remove `jcenter()` and other kotlin bintray repositories from
1269
1.1.0-RC / 2021-02-03
1370
==================
1471

15-
This is a release candidate of 1.1.0 version. Note that final 1.1.0 version may include more features and bugfixes,
72+
This is a release candidate of 1.1.0 version. Note that final 1.1.0 version may include more features and bugfixes,
1673
which would be listed in the corresponding changelog.
1774

1875
### Kotlin version requirement updated
1976

20-
Due to changes in calling conventions between compiler plugin and serialization core runtime, this release requires
77+
Due to changes in calling conventions between compiler plugin and serialization core runtime, this release requires
2178
Kotlin version at least 1.4.30-M1. However, this changes should not affect your code,
2279
because only deprecated functions were removed from public API.
2380
See [corresponding PR](https://github.com/Kotlin/kotlinx.serialization/pull/1260) for the details.
2481

2582
### Experimental support for inline classes (IR only)
2683

27-
Using 1.1.0-RC, you can mark inline classes as `@Serializable` and use them in other serializable classes.
84+
Using 1.1.0-RC, you can mark inline classes as `@Serializable` and use them in other serializable classes.
2885
Unsigned integer types (`UByte`, `UShort`, `UInt` and `ULong`) are serializable as well and have special support in JSON.
2986
This feature requires Kotlin compiler 1.4.30-RC and enabling new IR compilers for [JS](https://kotlinlang.org/docs/reference/js-ir-compiler.html) and [JVM](https://kotlinlang.org/docs/reference/whatsnew14.html#new-jvm-ir-backend).
3087

@@ -36,7 +93,7 @@ and corresponding [pull request](https://github.com/Kotlin/kotlinx.serialization
3693
* Add `serializerOrNull` function for `KType` and `Type` arguments (#1164)
3794
* Allow shared prefix names in `Properties` (#1183) (thanks to [TorRanfelt](https://github.com/TorRanfelt))
3895
* Add support for encoding/decoding `Properties` values as Strings (#1158) (thanks to [daniel-jasinski](https://github.com/daniel-jasinski))
39-
96+
4097
### Bugfixes and performance improvements
4198

4299
* Support contextual serialization for derived classes (#1277) (thanks to [Martin Raison](https://github.com/martinraison))
@@ -62,30 +119,30 @@ This patch release contains several feature improvements as well as bugfixes and
62119
* Add object-based serialization and deserialization of polymorphic types for `dynamic` conversions on JS platform (#1122)
63120
* Add support for object polymorphism in HOCON decoder (#1136)
64121
* Add support of decoding map in the root of HOCON config (#1106)
65-
122+
66123
### Bugfixes
67124
* Properly cache generated serializers in PluginGeneratedSerialDescriptor (#1159)
68125
* Add Pair and Triple to serializer resolving from Java type token (#1160)
69126
* Fix deserialization of half-precision, float and double types in CBOR (#1112)
70127
* Fix ByteString annotation detection when ByteArray is nullable (#1139)
71-
128+
72129
1.0.0 / 2020-10-08
73130
==================
74131

75132
The first public stable release, yay!
76133
The definitions of stability and backwards compatibility guarantees are located in the [corresponding document](docs/compatibility.md).
77134
We now also have a GitHub Pages site with [full API reference](https://kotlin.github.io/kotlinx.serialization/).
78135

79-
Compared to RC2, no new features apart from #947 were added and all previously deprecated declarations and migrations were deleted.
136+
Compared to RC2, no new features apart from #947 were added and all previously deprecated declarations and migrations were deleted.
80137
If you are using RC/RC2 along with deprecated declarations, please, migrate before updating to 1.0.0.
81138
In case you are using pre-1.0 versions (e.g. 0.20.0), please refer to our [migration guide](docs/migration.md).
82-
139+
83140
### Bugfixes and improvements
84141

85142
* Support nullable types at top-level for JsonElement decoding (#1117)
86143
* Add CBOR ignoreUnknownKeys option (#947) (thanks to [Travis Wyatt](https://github.com/twyatt))
87144
* Fix incorrect documentation of `encodeDefaults` (#1108) (thanks to [Anders Carling](https://github.com/anderscarling))
88-
145+
89146
1.0.0-RC2 / 2020-09-21
90147
==================
91148

@@ -110,7 +167,7 @@ writing a library that depends on kotlinx.serialization in a format-agnostic way
110167
* `encodeDefaults` flag is now set to `false` in the default configuration for JSON, CBOR and Protocol Buffers.
111168

112169
The change is motivated by the fact that in most real-life scenarios, this flag is set to `false` anyway,
113-
because such configuration reduces visual clutter and saves amount of data being serialized.
170+
because such configuration reduces visual clutter and saves amount of data being serialized.
114171
Other libraries, like GSON and Moshi, also have this behavior by default.
115172

116173
This may change how your serialized data looks like, if you have not set value for `encodeDefaults` flag explicitly.
@@ -144,8 +201,8 @@ To migrate, simply add `import kotlinx.serialization.json.*` to your files.
144201
Release candidate for 1.0.0 version. The goal of RC release is to collect feedback from users
145202
and provide 1.0.0 release with bug fixes and improvements based on that feedback.
146203

147-
While working on 1.0.0 version, we carefully examined every public API declaration of the library and
148-
split it to stable API, that we promise to be source and binary-compatible,
204+
While working on 1.0.0 version, we carefully examined every public API declaration of the library and
205+
split it to stable API, that we promise to be source and binary-compatible,
149206
and experimental API, that may be changed in the future.
150207
Experimental API is annotated with `@ExperimentalSerializationApi` annotation, which requires opt-in.
151208
For a more detailed description of the guarantees, please refer to the [compatibility guide](docs/compatibility.md).
@@ -180,7 +237,7 @@ of `Json {}` builder
180237
* Redundant members of `JsonElement` API are deprecated or extracted to extensions
181238
* Potential error-prone API is removed
182239
* `JsonLiteral` is deprecated in favor of `JsonPrimitive` constructors with nullable parameter
183-
240+
184241
* `JsonElement` builders rework to be aligned with stdlib collection builders (#418, #627)
185242
* Deprecated infix `to` and unaryPlus in JSON DSL in favor of `put`/`add` functions
186243
* `jsonObject {}` and `json {}` builders are renamed to `buildJsonObject {}` and `buildJsonArray {}`
@@ -195,20 +252,20 @@ of `Json {}` builder
195252
* Methods in `JsonTransformingSerializer` are renamed to `transformSerialize` and `transformDeserialize`
196253
* `JsonParametricSerializer` is renamed to `JsonContentPolymorphicSerializer`
197254
* `JsonEncodingException` and `JsonDecodingException` are made internal
198-
255+
199256
* Bug fixes
200257
* `IllegalStateException` when `null` occurs in JSON input in the place of an expected non-null object (#816)
201258
* java.util.NoSuchElementException when deserializing twice from the same JsonElement (#807)
202259

203-
#### Core API for format authoring
260+
#### Core API for format authoring
204261

205262
* The new naming scheme for `SerialFormats`
206263
* Core functions in `StringFormat` and `BinaryFormat` are renamed and now follow the same naming scheme
207264
* `stringify`/`parse` are renamed to `encodeToString`/`decodeFromString`
208265
* `encodeToByteArray`/`encodeToHexString`/`decodeFromByteArray`/`decodeFromHexString` in `BinaryFormat` are introduced instead of `dump`/`dumps`/`load`/`loads`
209266

210267
* New format instances building convention
211-
* Constructors replaced with builder-function with the same name to have the ability to add new configuration parameters,
268+
* Constructors replaced with builder-function with the same name to have the ability to add new configuration parameters,
212269
while preserving both source and binary compatibility
213270
* Format's companion objects now extend format class and can be used interchangeably
214271

@@ -231,15 +288,15 @@ of `Json {}` builder
231288
* Contextual serialization
232289
* `@ContextualSerialization` is split into two annotations: `@Contextual` to use on properties and `@UseContextualSerialization` to use on file
233290
* New `SerialDescriptor.capturedKClass` API to introspect SerializersModule-based contextual and polymorphic kinds (#515, #595)
234-
291+
235292
* Encoding-related API
236293
* Encoding-related classes (`Encoder`, `Decoder`, `AbstractEncoder`, `AbstractDecoder`) are moved to a separate `kotlinx.serialization.encoding` package
237294
* Deprecated `typeParameters` argument in `beginStructure`/`beginCollectio`n methods
238295
* Deprecated `updateSerializableValue` and similar methods and `UpdateMode` enum
239-
* Renamed `READ_DONE` to `DECODE_DONE`
296+
* Renamed `READ_DONE` to `DECODE_DONE`
240297
* Make extensions `inline` where applicable
241298
* `kotlinx.io` mockery (`InputStream`, `ByteArrayInput`, etc) is removed
242-
299+
243300
* Serializer-related API
244301
* `UnitSerializer` is replaced with `Unit.serializer()`
245302
* All methods for serializers retrieval are renamed to `serializer`
@@ -249,7 +306,7 @@ of `Json {}` builder
249306
* Support of custom serializers for nullable types is added (#824)
250307

251308
#### ProtoBuf
252-
309+
253310
* `ProtoBuf` constructor is replaced with `ProtoBuf {}` builder function
254311
* `ProtoBuf` companion object now extends `ProtoBuf`
255312
* `ProtoId` is renamed to `ProtoNumber`, `ProtoNumberType` to `ProtoIntegerType` to be consistent with ProtoBuf specification
@@ -261,7 +318,7 @@ of `Json {}` builder
261318
#### Other formats
262319
* All format constructors are migrated to builder scheme
263320
* Properties serialize and deserialize enums as strings (#818)
264-
* CBOR major type 2 (byte string) support (#842)
321+
* CBOR major type 2 (byte string) support (#842)
265322
* `ConfigParser` is renamed to `Hocon`, `kotlinx-serialization-runtime-configparser` artifact is renamed to `kotlinx-serialization-hocon`
266323
* Do not write/read size of collection into Properties' map (#743)
267324

@@ -270,18 +327,18 @@ of `Json {}` builder
270327

271328
### Release notes
272329

273-
0.20.0 release is focused on giving a library its final and stable API shape.
330+
0.20.0 release is focused on giving a library its final and stable API shape.
274331

275332
We have carefully evaluated every `public` declaration and
276333
decided whether it should be publicly available. As a result, some declarations were deprecated with an intention of removing
277-
them from public API because they are going to be replaced with others, more valuable and useful for users.
334+
them from public API because they are going to be replaced with others, more valuable and useful for users.
278335

279-
Deprecated symbols include:
336+
Deprecated symbols include:
280337
- Pre-defined JSON instances like `nonStrict``strictMode` was split to 3 separate, more granular, flags.
281-
Users are encouraged to create their own configuration;
338+
Users are encouraged to create their own configuration;
282339
- Top-level serializers like `IntSerializer` and `ArrayListSerializer`.
283340
They were replaced with constructor-like factory functions.
284-
- `SerialClassDescImpl` creation class replaced with `SerialDescriptor`
341+
- `SerialClassDescImpl` creation class replaced with `SerialDescriptor`
285342
builder function to ease writing of custom serializers and maintain `SerialDescriptor` contract.
286343
- Internal utilities, like HexConverter and ByteBuffer, were deprecated as not relevant to serialization public API.
287344
- Add-on formats like Protobuf, CBOR and Properties (formerly Mapper)
@@ -290,18 +347,18 @@ are now extracted to [separate artifacts](formats/README.md#protobuf) to keep th
290347
We have spent a lot of effort into the quality,
291348
documenting most of the core interfaces, establishing their contracts,
292349
fixing numerous of bugs, and even introducing new features that may be useful for those of you who
293-
write custom serializers — see [JsonTransformingSerializer](docs/json_transformations.md).
350+
write custom serializers — see [JsonTransformingSerializer](docs/json_transformations.md).
294351

295352
Such API changes, of course, may be not backwards-compatible in some places, in particular, between compiler plugin and runtime.
296353
Given that the library is still is in the experimental phase, we took the liberty to introduce breaking changes in order to give users
297354
the better, more convenient API. Therefore, this release has number `0.20.0` instead of `0.15.0`;
298355
Kotlin 1.3.70 is compatible _only_ with this release.
299356

300-
To migrate:
357+
To migrate:
301358
1. Replace `import kotlinx.serialization.internal.*` with `import kotlinx.serialization.builtins.*`.
302359
This action is sufficient for most of the cases, except primitive serializers — instead of using `IntSerializer`, use `Int.serializer()`.
303360
For other object-like declarations, you may need to transform it to function call: `ByteArraySerializer` => `ByteArraySerializer()`.
304-
361+
305362
2. Pay attention to the changed `JsonConfiguration` constructor arguments: instead of `strictMode`,
306363
now three different flags are available: `ignoreUnknownKeys`, `isLenient`, and `serializeSpecialFloatingPointValues`.
307364

@@ -312,8 +369,8 @@ because now they're located outside of core module. See [formats list](formats/R
312369
(use Alt+Enter for quickfix replacing).
313370

314371
### Full changelog (by commit):
315-
316-
* This release is compatible with Kotlin 1.3.70
372+
373+
* This release is compatible with Kotlin 1.3.70
317374
* Rework polymorphic descriptors: polymorphic and sealed descriptor elements are now aligned with an actual serialization process (#731)
318375
* Hide internal collection and map serializers
319376
* Introduce factories for ArraySerializers as well, deprecate top-level array serializers

0 commit comments

Comments
 (0)