What Is NOT in Common stdlib
JVM-only APIs to avoid in commonMain.
What Is NOT in Common stdlib is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Common Has Limits
Not every Kotlin API is multiplatform. The common stdlib is a careful subset, and many familiar JVM tools are missing.
No java.* in Common
Anything under java packages is JVM-only. It compiles on Android but breaks the moment iOS tries to build it.
java.util.Date Is Out
The old java.util.Date and Calendar do not exist in common code. Reach for kotlinx-datetime instead.
No File or Path Here
JVM file APIs like java.io.File are absent from commonMain. File access needs a multiplatform library or expect/actual.
Reflection Is Limited
Full reflection is a JVM feature. Common code only gets a tiny subset, so design without heavy runtime introspection.
Threads Look Different
java.lang.Thread is unavailable in common. For background work you use coroutines, which are fully multiplatform.
How To Spot a Trap
If an import starts with java or javax, it cannot live in commonMain. That prefix is your warning sign.
import java.util.UUIDThe Compiler Catches You
Put JVM-only code in common and the build fails fast with an unresolved reference for the iOS target. That is helpful, not scary.
Two Ways Out
When you need a platform API, either find a multiplatform library or wrap it yourself with expect/actual per target.
Stay in the Safe Zone
Stick to Kotlin stdlib types and kotlinx libraries in common, and your shared layer stays portable everywhere. 🙂
Plan Before You Code
Before sharing logic, ask whether it needs a JVM-only API. If so, isolate it so commonMain stays clean.
Quick Check
Which import does NOT belong in commonMain?
Recap
Avoid java.* APIs in commonMain. Use stdlib types, kotlinx libraries, or expect/actual to keep shared code truly portable.
Frequently asked questions
Is the “What Is NOT in Common stdlib” lesson free?
Yes — the full text of “What Is NOT in Common stdlib” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.
What will I learn in “What Is NOT in Common stdlib”?
JVM-only APIs to avoid in commonMain. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Multiplatform Academy?
No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “What Is NOT in Common stdlib” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Multiplatform Academy lesson?
Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Strings, Numbers & Collections Everywhere
- map, filter & fold in Shared Code
- Dates with kotlinx-datetime
- What Is NOT in Common stdlib