# Libraries

**URL:** https://discuss.kotlinlang.org/c/libraries/11.md

[Latest](https://discuss.kotlinlang.org/latest.md) · [Categories](https://discuss.kotlinlang.org/categories.md)

---

## [About the Libraries category](https://discuss.kotlinlang.org/t/about-the-libraries-category/1338)

<div class="topic-metadata">

**Author:** [@Roman\_Belov](https://discuss.kotlinlang.org/u/Roman_Belov)\
**Replies:** 0\
**Last updated:** [December 4, 2015, 7:57am UTC](https://discuss.kotlinlang.org/t/about-the-libraries-category/1338 "2015-12-04T07:57:35Z")

</div>

Using the Kotlin standard library and other kotlinx libraries. See also relevant channels in Kotlin Slack (you can sign up here): #stdlib #coroutines #serialization #ktor

---

## [Kotlin-rate-limiter](https://discuss.kotlinlang.org/t/kotlin-rate-limiter/31032)

<div class="topic-metadata">

**Author:** [@delder004](https://discuss.kotlinlang.org/u/delder004)\
**Replies:** 0\
**Last updated:** [April 14, 2026, 12:02am UTC](https://discuss.kotlinlang.org/t/kotlin-rate-limiter/31032 "2026-04-14T00:02:02Z")

</div>

Looking for feedback and users! I built a small library in this space that may be useful as a reference implementation: https://github.com/delder004/kotlin-rate-limiter It’s a coroutine-native rate limiter for outbound…

---

## [Kotlin.document.store - Fast NoSql document store for Kotlin Multiplatform](https://discuss.kotlinlang.org/t/kotlin-document-store-fast-nosql-document-store-for-kotlin-multiplatform/29658)

<div class="topic-metadata">

**Author:** [@lamba92](https://discuss.kotlinlang.org/u/lamba92)\
**Replies:** 2\
**Last updated:** [January 20, 2026, 1:21pm UTC](https://discuss.kotlinlang.org/t/kotlin-document-store-fast-nosql-document-store-for-kotlin-multiplatform/29658 "2026-01-20T13:21:14Z")

</div>

Hey! Check out kotlin.document.store. Any feedback would be greatly appreciated!

---

## [Why does takeIf allow nullable receivers in its predicate?](https://discuss.kotlinlang.org/t/why-does-takeif-allow-nullable-receivers-in-its-predicate/30863)

<div class="topic-metadata">

**Author:** [@fvasco](https://discuss.kotlinlang.org/u/fvasco)\
**Replies:** 0\
**Last updated:** [November 25, 2025, 1:25pm UTC](https://discuss.kotlinlang.org/t/why-does-takeif-allow-nullable-receivers-in-its-predicate/30863 "2025-11-25T13:25:45Z")

</div>

The signature of takeIf (and takeUnless) is: public inline fun \<T\> T.takeIf(predicate: (T) -\> Boolean): T? instead of: public inline fun \<T : Any\> T?.takeIf(predicate: (T) -\> Boolean): T? Why does Kotlin allow null a…

---

## [Exposed-kotlin-datetime](https://discuss.kotlinlang.org/t/exposed-kotlin-datetime/22976)

<div class="topic-metadata">

**Author:** [@huggy](https://discuss.kotlinlang.org/u/huggy)\
**Replies:** 2\
**Last updated:** [November 19, 2025, 8:56am UTC](https://discuss.kotlinlang.org/t/exposed-kotlin-datetime/22976 "2025-11-19T08:56:12Z")

</div>

i see this module in the exposed source, yet i cannot find it in any maven repository. How can i use use this. The library basically lets us use the kotlin localdatetime instead of the java version.

---

## [withContext breaks coroutine supervision](https://discuss.kotlinlang.org/t/withcontext-breaks-coroutine-supervision/30821)

<div class="topic-metadata">

**Author:** [@alexis](https://discuss.kotlinlang.org/u/alexis)\
**Replies:** 7\
**Last updated:** [November 9, 2025, 12:52pm UTC](https://discuss.kotlinlang.org/t/withcontext-breaks-coroutine-supervision/30821 "2025-11-09T12:52:38Z")

</div>

I have the following exception handler (just as example): class StatefulCoroutineExceptionHandler( private val logging: Boolean ) : CoroutineExceptionHandler { val throwables = mutableListOf\<Throwable\>() ov…

---

## [Time out for reading from a stream](https://discuss.kotlinlang.org/t/time-out-for-reading-from-a-stream/30740)

<div class="topic-metadata">

**Author:** [@moddy\_te\_eni](https://discuss.kotlinlang.org/u/moddy_te_eni)\
**Replies:** 4\
**Last updated:** [September 16, 2025, 2:24pm UTC](https://discuss.kotlinlang.org/t/time-out-for-reading-from-a-stream/30740 "2025-09-16T14:24:19Z")

</div>

I use InputStream.read() to read from a pipe after creating a sub-process. I had a problem that the process got stuck, so I wrote a quite complicated code with coroutines, sleep, available() and other tests to make sure…

---

## [Kotlin doesn't play nice with Beans Validation annotations and this needs to be addressed](https://discuss.kotlinlang.org/t/kotlin-doesnt-play-nice-with-beans-validation-annotations-and-this-needs-to-be-addressed/27761)

<div class="topic-metadata">

**Author:** [@martin.haeusler](https://discuss.kotlinlang.org/u/martin.haeusler)\
**Replies:** 6\
**Last updated:** [August 29, 2025, 12:32pm UTC](https://discuss.kotlinlang.org/t/kotlin-doesnt-play-nice-with-beans-validation-annotations-and-this-needs-to-be-addressed/27761 "2025-08-29T12:32:28Z")

</div>

Spring and Spring Boot are what I would call “kotlin-friendly” frameworks. However, the beans validation aspect specifically just doesn’t play nice with kotlin. Here’s why. Let’s assume the following data class: data c…

---

## [How many NoSuchFileException we expected?](https://discuss.kotlinlang.org/t/how-many-nosuchfileexception-we-expected/30680)

<div class="topic-metadata">

**Author:** [@cpdyj](https://discuss.kotlinlang.org/u/cpdyj)\
**Replies:** 2\
**Last updated:** [August 7, 2025, 7:17pm UTC](https://discuss.kotlinlang.org/t/how-many-nosuchfileexception-we-expected/30680 "2025-08-07T19:17:11Z")

</div>

I create a library to parse object and executable files. When the given file is not exists, I throw the my.NoSuchFileException. I think it’s good, because the file is really not exists. On JVM, since there’s a java.nio.…

---

## [Kotlin Script Execution Not Working in OSGI Environment](https://discuss.kotlinlang.org/t/kotlin-script-execution-not-working-in-osgi-environment/30560)

<div class="topic-metadata">

**Author:** [@codewithhs](https://discuss.kotlinlang.org/u/codewithhs)\
**Replies:** 0\
**Last updated:** [July 8, 2025, 8:06am UTC](https://discuss.kotlinlang.org/t/kotlin-script-execution-not-working-in-osgi-environment/30560 "2025-07-08T08:06:57Z")

</div>

Hi, I’m working on integrating Kotlin scripting support into an OSGi environment. The project is Maven-based, and I’ve included all the necessary dependencies for .kts script execution. Currently, I’m using a shaded (fa…

---

## [\`Sequence.sorted\*\` methods](https://discuss.kotlinlang.org/t/sequence-sorted-methods/1922)

<div class="topic-metadata">

**Author:** [@mfulton26](https://discuss.kotlinlang.org/u/mfulton26)\
**Replies:** 7\
**Last updated:** [June 28, 2025, 1:09pm UTC](https://discuss.kotlinlang.org/t/sequence-sorted-methods/1922 "2025-06-28T13:09:43Z")

</div>

I was surprised to find the following methods in the standard library in the kotlin.sequences package: sorted sortedBy sortedByDescending sortedDescending sortedWith These methods convert a sequence to a mutable list,…

---

## [Explicit dependencies for coroutines](https://discuss.kotlinlang.org/t/explicit-dependencies-for-coroutines/13775)

<div class="topic-metadata">

**Author:** [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Replies:** 11\
**Last updated:** [August 7, 2019, 6:21pm UTC](https://discuss.kotlinlang.org/t/explicit-dependencies-for-coroutines/13775 "2019-08-07T18:21:46Z")

</div>

I am currently refactoring some of my libraries, because it seems like current coroutines solve most of problems, I’ve tried to solve myself. The only question that remains are the dependencies. I have a task graph, wher…

---

## [Improved Any?.toString](https://discuss.kotlinlang.org/t/improved-any-tostring/30309)

<div class="topic-metadata">

**Author:** [@crazo7924](https://discuss.kotlinlang.org/u/crazo7924)\
**Replies:** 1\
**Last updated:** [May 3, 2025, 2:47pm UTC](https://discuss.kotlinlang.org/t/improved-any-tostring/30309 "2025-05-03T14:47:07Z")

</div>

I love the fact that we have Any?.toString but it returns “null” when the receiver is (duh) null. Instead of this, we could pass an optional String parameter which could be the return value. My implementation: fun Any…

---

## [How do you specify a transition in the kotlinx.html DSL?](https://discuss.kotlinlang.org/t/how-do-you-specify-a-transition-in-the-kotlinx-html-dsl/27720)

<div class="topic-metadata">

**Author:** [@shemitz](https://discuss.kotlinlang.org/u/shemitz)\
**Replies:** 2\
**Last updated:** [April 21, 2025, 2:36am UTC](https://discuss.kotlinlang.org/t/how-do-you-specify-a-transition-in-the-kotlinx-html-dsl/27720 "2025-04-21T02:36:22Z")

</div>

I posted this on slashdot, but maybe I’ll get an answer here :wink: I’m building a web toy using the kotlinx DSL, and trying to do the equivalent of adding transition: color 1s. I expect that within a css {} block, I sh…

---

## [applyIf and letIf?](https://discuss.kotlinlang.org/t/applyif-and-letif/26390)

<div class="topic-metadata">

**Author:** [@BoD](https://discuss.kotlinlang.org/u/BoD)\
**Replies:** 22\
**Last updated:** [April 13, 2025, 12:39pm UTC](https://discuss.kotlinlang.org/t/applyif-and-letif/26390 "2025-04-13T12:39:42Z")

</div>

I very often find myself doing this: foo = bar .let { if (someCondition) { it.baz() } else { it } } and similarly with apply: foo = bar .apply { if (someCondition) { baz() }…

---

## [Kotlin v2 and Spring JPA v3.4, always reports \`InstantiationException: Could not instantiate entity\`\`](https://discuss.kotlinlang.org/t/kotlin-v2-and-spring-jpa-v3-4-always-reports-instantiationexception-could-not-instantiate-entity/30088)

<div class="topic-metadata">

**Author:** [@linzuxiong2000](https://discuss.kotlinlang.org/u/linzuxiong2000)\
**Replies:** 2\
**Last updated:** [March 16, 2025, 7:33am UTC](https://discuss.kotlinlang.org/t/kotlin-v2-and-spring-jpa-v3-4-always-reports-instantiationexception-could-not-instantiate-entity/30088 "2025-03-16T07:33:17Z")

</div>

Help, anyone can help me ? My project uses kotlin v2.1 and spring jpa v3.4! The show code files are below, it can be built ok, but can not run

---

## [How do functions indicate their suspension points to coroutines?](https://discuss.kotlinlang.org/t/how-do-functions-indicate-their-suspension-points-to-coroutines/30003)

<div class="topic-metadata">

**Author:** [@limayehnl2712](https://discuss.kotlinlang.org/u/limayehnl2712)\
**Replies:** 14\
**Last updated:** [March 8, 2025, 10:49am UTC](https://discuss.kotlinlang.org/t/how-do-functions-indicate-their-suspension-points-to-coroutines/30003 "2025-03-08T10:49:58Z")

</div>

I am learning about coroutines and reading the Coroutines and channels − tutorial. I have also read this article which explains a common misconception. From what I understand so far, coroutines do not inherently turn bl…

---

## [What is the standard library to use when dealing with money in Kotlin?](https://discuss.kotlinlang.org/t/what-is-the-standard-library-to-use-when-dealing-with-money-in-kotlin/29925)

<div class="topic-metadata">

**Author:** [@DanielCoder834](https://discuss.kotlinlang.org/u/DanielCoder834)\
**Replies:** 14\
**Last updated:** [February 18, 2025, 11:55pm UTC](https://discuss.kotlinlang.org/t/what-is-the-standard-library-to-use-when-dealing-with-money-in-kotlin/29925 "2025-02-18T23:55:09Z")

</div>

I am trying to represent the value of money that supports other currencies and conversion between them and has 100% precision in mathematical operation. Is it better to build an implementation to represent money from the…

---

## [Why coroutine dispatcher is so invasive?](https://discuss.kotlinlang.org/t/why-coroutine-dispatcher-is-so-invasive/29683)

<div class="topic-metadata">

**Author:** [@minogin](https://discuss.kotlinlang.org/u/minogin)\
**Replies:** 7\
**Last updated:** [January 15, 2025, 5:04pm UTC](https://discuss.kotlinlang.org/t/why-coroutine-dispatcher-is-so-invasive/29683 "2025-01-15T17:04:03Z")

</div>

Consider the following example: @Test fun test(): Unit = runBlocking { f() } private suspend fun f() = coroutineScope { launch { println("Job 1: ${Thread.currentThread().name}") } launch { …

---

## [Why buildMap uses custom map implementation instead of HashMap?](https://discuss.kotlinlang.org/t/why-buildmap-uses-custom-map-implementation-instead-of-hashmap/29705)

<div class="topic-metadata">

**Author:** [@stas.garifulin](https://discuss.kotlinlang.org/u/stas.garifulin)\
**Replies:** 4\
**Last updated:** [January 7, 2025, 7:43am UTC](https://discuss.kotlinlang.org/t/why-buildmap-uses-custom-map-implementation-instead-of-hashmap/29705 "2025-01-07T07:43:09Z")

</div>

In Kotlin’s standard library, there’s a class named kotlin.collections.builders.MapBuilder, which implements MutableMap using a hash table. Instances of this class are created using the buildMap function, introduced in K…

---

## [toDigits() function for Int](https://discuss.kotlinlang.org/t/todigits-function-for-int/15298)

<div class="topic-metadata">

**Author:** [@Linus789](https://discuss.kotlinlang.org/u/Linus789)\
**Replies:** 6\
**Last updated:** [December 22, 2024, 4:21pm UTC](https://discuss.kotlinlang.org/t/todigits-function-for-int/15298 "2024-12-22T16:21:09Z")

</div>

Hello everyone, I’m really missing a useful function in Kotlin. Right now the only way to convert an Int to a List of Digits (Int) is to create a method or use toString which is rather ugly. Could you provide a functio…

---

## [\[feature request\] add overloaded operators for nullable collection types](https://discuss.kotlinlang.org/t/feature-request-add-overloaded-operators-for-nullable-collection-types/29643)

<div class="topic-metadata">

**Author:** [@gusega](https://discuss.kotlinlang.org/u/gusega)\
**Replies:** 15\
**Last updated:** [December 19, 2024, 8:28pm UTC](https://discuss.kotlinlang.org/t/feature-request-add-overloaded-operators-for-nullable-collection-types/29643 "2024-12-19T20:28:27Z")

</div>

So that I can return listA + listB if both lists can be null instead of return when { listA == null -\> listB listB == null -\> listA else -\> listA + listB } Maybe also support + for non-nullable collection when…

---

## [Would this flow operator leak StateFlows?](https://discuss.kotlinlang.org/t/would-this-flow-operator-leak-stateflows/29573)

<div class="topic-metadata">

**Author:** [@nbransby](https://discuss.kotlinlang.org/u/nbransby)\
**Replies:** 1\
**Last updated:** [December 4, 2024, 6:21am UTC](https://discuss.kotlinlang.org/t/would-this-flow-operator-leak-stateflows/29573 "2024-12-04T06:21:06Z")

</div>

Would the StateFlows be retained via the scope passed into stateIn after they have been removed from the flows map? inline fun \<K, T, R\> SharedFlow\<Map\<K, T\>\>.flatMapLatestValues( crossinline transform: suspend (val…

---

## [Java reflection and Kotlin primitive types](https://discuss.kotlinlang.org/t/java-reflection-and-kotlin-primitive-types/18346)

<div class="topic-metadata">

**Author:** [@stachenov](https://discuss.kotlinlang.org/u/stachenov)\
**Replies:** 12\
**Last updated:** [November 26, 2024, 7:52am UTC](https://discuss.kotlinlang.org/t/java-reflection-and-kotlin-primitive-types/18346 "2024-11-26T07:52:53Z")

</div>

IDEA warns me that Java boxed types shouldn’t be used, and that I should use respective Kotlin types instead. It works most of the time, but sometimes leads to unexpected results. Here’s an example. class Property\<T\> pr…

---

## [Polymorphic serialization doesn't work for deeper sealed class hierarchies](https://discuss.kotlinlang.org/t/polymorphic-serialization-doesnt-work-for-deeper-sealed-class-hierarchies/20534)

<div class="topic-metadata">

**Author:** [@avwie](https://discuss.kotlinlang.org/u/avwie)\
**Replies:** 5\
**Last updated:** [September 17, 2024, 7:33am UTC](https://discuss.kotlinlang.org/t/polymorphic-serialization-doesnt-work-for-deeper-sealed-class-hierarchies/20534 "2024-09-17T07:33:09Z")

</div>

I have the following code: @Serializable sealed class Component : Tagged\<UUID, Component\> { @Serializable @SerialName("name") data class Name(val name: String, @Transient override val tag: Tag\<Component\> = Tag.…

---

## [Kotlin reflection javaMethod() only returns raw type of List as return type](https://discuss.kotlinlang.org/t/kotlin-reflection-javamethod-only-returns-raw-type-of-list-as-return-type/29143)

<div class="topic-metadata">

**Author:** [@yangziii920](https://discuss.kotlinlang.org/u/yangziii920)\
**Replies:** 6\
**Last updated:** [August 28, 2024, 8:02am UTC](https://discuss.kotlinlang.org/t/kotlin-reflection-javamethod-only-returns-raw-type-of-list-as-return-type/29143 "2024-08-28T08:02:33Z")

</div>

Have a method that returns List of String like below: class SampleClass { fun sampleMethod(): List\<String\> { return listOf() } } When I use Kotlin reflection library to get the method signature, I’d exp…

---

## [Coroutines with debug duplicates exception](https://discuss.kotlinlang.org/t/coroutines-with-debug-duplicates-exception/29103)

<div class="topic-metadata">

**Author:** [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Replies:** 10\
**Last updated:** [August 26, 2024, 12:48pm UTC](https://discuss.kotlinlang.org/t/coroutines-with-debug-duplicates-exception/29103 "2024-08-26T12:48:50Z")

</div>

Hi all, I’ve found what I consider to be a bug with coroutines and exception handling. In summary, if you throw an exception inside a suspending function, and the exception either has no cause, or has a cause with a dif…

---

## [Multiplatform 3D graphics library](https://discuss.kotlinlang.org/t/multiplatform-3d-graphics-library/13600)

<div class="topic-metadata">

**Author:** [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Replies:** 13\
**Last updated:** [August 19, 2024, 7:08am UTC](https://discuss.kotlinlang.org/t/multiplatform-3d-graphics-library/13600 "2024-08-19T07:08:50Z")

</div>

There is a new interesting development in 3D rendering. Lars Ivar Hatledal just announced full kotlin-jvm port of three-js library: GitHub - markaren/three.kt: Three.js port for the JVM (desktop). It is not JS wrapper, b…

---

## [Problem with select](https://discuss.kotlinlang.org/t/problem-with-select/29039)

<div class="topic-metadata">

**Author:** [@Pythonista7](https://discuss.kotlinlang.org/u/Pythonista7)\
**Replies:** 6\
**Last updated:** [August 12, 2024, 12:41pm UTC](https://discuss.kotlinlang.org/t/problem-with-select/29039 "2024-08-12T12:41:25Z")

</div>

I believe im trying to do something common when working with coroutines , passing a error channel in an object which awaits confirmation from the errC that it executed successfully. But i don’t understand why the newRes…

---

## [Why is \`Iterable\<Float\>.sumOf\`not available in stdlib?](https://discuss.kotlinlang.org/t/why-is-iterable-float-sumof-not-available-in-stdlib/29031)

<div class="topic-metadata">

**Author:** [@hanggrian](https://discuss.kotlinlang.org/u/hanggrian)\
**Replies:** 0\
**Last updated:** [August 9, 2024, 11:53am UTC](https://discuss.kotlinlang.org/t/why-is-iterable-float-sumof-not-available-in-stdlib/29031 "2024-08-09T11:53:25Z")

</div>

I noticed that kotlin.collections.sumBy and kotlin.collections.sumDouble have been deprecated, replaced with kotlin.collections.sumOf. Along with Int and Double, sumOf also supports many other number types such as Long a…

[Next page](https://discuss.kotlinlang.org/c/libraries/11.md?page=1)
