Kotlin — References¶
Sources used for chapter 05 — Kotlin, grouped by purpose. Every entry has a one-line note explaining what it is good for. Where a resource is best known by name rather than by a stable URL, it is named rather than linked, so nothing here is invented.
1. Official Kotlin language documentation¶
- Kotlin Documentation home — the entry point to every official topic page; start here when a construct is unfamiliar.
- Kotlin language specification — the normative document defining semantics; the only place that settles arguments about corner cases.
- Basic syntax — the fastest orientation for a reader arriving from Java.
- Null safety — nullable types, safe calls, the Elvis operator, the not-null assertion, and platform types.
- Type checks and casts —
is,as,as?, and smart casts, which explain many odd-looking decompiled branches. - Classes and inheritance — primary constructors,
initblocks, and the final-by-default rule. - Data classes — states exactly which members the compiler generates, which is the contract you rely on when reading JADX.
- Sealed classes and interfaces — the restricted hierarchy rules that produce
DefaultConstructorMarkerconstructors. - Object declarations and expressions — the source of the
INSTANCEfield and theCompanionnested class. - Extensions — explains static dispatch and why extensions are not members.
- Functions — default arguments, named arguments, varargs, and infix functions.
- Higher-order functions and lambdas — function types,
it, closures, and receivers. - Inline functions — inlining,
noinline,crossinline,reified, and non-local returns. - Scope functions — the official selection table for
let,run,with,apply, andalso. - Delegated properties —
by lazy,Delegates.observable, and thegetValue/setValuecontract. - Delegation — interface delegation with
by, which produces the$$delegate_0field. - Generics — declaration-site variance with
inandout, star projections, and type erasure. - Collections overview — the read-only versus mutable distinction and why it is compile-time only.
- Sequences — lazy evaluation and when it beats eager collection operators.
- Coding conventions — the naming rules that let you guess a symbol's role from its shape.
- The per-version "What's new in Kotlin" pages on
kotlinlang.org/docs— useful for dating an APK's compiler generation from which helper names it emits, for examplecheckParameterIsNotNullbefore Kotlin 1.4 versuscheckNotNullParameterafter it.
2. Coroutines and concurrency¶
- Coroutines guide — the official tutorial series covering builders, context, channels, and flows.
- Coroutines basics — suspending functions, scope, and the first mental model.
- Composing suspending functions — sequential versus concurrent composition with
async. - Coroutine context and dispatchers — the definitive description of
Dispatchers.Main,Default,IO, andUnconfined. - Cancellation and timeouts — why cancellation is cooperative and what
CancellationExceptionmeans. - Asynchronous flow — cold streams, operators,
flowOn, and back-pressure. - Exception handling — how failures propagate through a scope hierarchy and what
SupervisorJobchanges. - kotlinx.coroutines on GitHub — the library implementation; read
BaseContinuationImplandDispatchedTaskto see the machinery your Frida hooks attach to. - kotlinx.coroutines API reference — signatures for every builder, dispatcher, and flow operator.
- Kotlin Evolution and Enhancement Process (KEEP) repository — the design documents behind every language feature, including the rationale nobody puts in the user docs.
- KEEP: coroutines design document — the single most valuable document for understanding Continuation Passing Style, the
COROUTINE_SUSPENDEDsentinel, and the state-machine transformation.
3. Java interoperability and the JVM back end¶
- Calling Java from Kotlin — platform types, SAM conversion, and mapped types.
- Calling Kotlin from Java — the authoritative description of
@JvmStatic,@JvmField,@JvmName,@JvmOverloads, and companion-object visibility from Java. - Kotlin and Java mixed-language projects — how the two compilers cooperate in one module.
- Android Kotlin-Java interop guide — Google's rules for writing API surfaces that stay pleasant from both languages.
- The
kotlin-metadata-jvmlibrary, in theJetBrains/kotlinrepository underlibraries/— the official parser for the@Metadataannotation; the correct way to read Kotlin declaration information out of a class file programmatically.
4. Android-specific Kotlin¶
- Android developers: Kotlin — the hub page for Kotlin on Android.
- Kotlin coroutines on Android —
lifecycleScope,viewModelScope, and the main-safety pattern. - Improve app performance with Kotlin coroutines — cancellation, exceptions, and the
withContextguidance most apps follow. - Kotlin flows on Android —
StateFlow,SharedFlow, and lifecycle-aware collection. - Android Kotlin style guide — the conventions that determine what generated names look like in a typical app.
- Jetpack Compose documentation — a Kotlin-only toolkit whose compiler plugin adds yet another layer of generated code you will meet in decompiled UIs.
- Kotlin Multiplatform documentation —
expect/actual, shared source sets, and how shared code still becomes ordinary DEX on Android.
5. Compiler, bytecode, and toolchain¶
- JetBrains/kotlin on GitHub — the compiler itself; the JVM back end is where every generated member described in this chapter is actually produced.
- Dalvik Executable format — the DEX header, string identifier table, and type descriptors that
scripts/detect-kotlin.pyparses. - Android: shrink, obfuscate, and optimize your app — how R8 treats Kotlin, including which
Intrinsicscalls it can remove. - R8 source repository — the shrinker and DEX compiler used by every modern Android build.
- JADX — the decompiler assumed throughout this chapter, including its Kotlin metadata support and
--deobfrenaming. - Apktool — resource decoding and smali round-tripping.
- smali and baksmali — the assembler and disassembler for the DEX format.
- Frida documentation — the instrumentation framework used in the labs.
- Frida JavaScript API reference —
Java.perform,Java.use,Java.choose, and overload resolution.
6. OWASP MASVS and MASTG¶
The OWASP Mobile Application Security project is the assessment framework this repository maps to. Kotlin-specific findings almost always land in one of the control groups below; consult the MASTG site for the current test identifiers, which are renumbered periodically.
- OWASP Mobile Application Security home — the umbrella project.
- OWASP MASVS — the verification standard; the control groups are
MASVS-STORAGE,MASVS-CRYPTO,MASVS-AUTH,MASVS-NETWORK,MASVS-PLATFORM,MASVS-CODE,MASVS-RESILIENCE, andMASVS-PRIVACY. - OWASP MASTG — the testing guide with concrete procedures and current test identifiers.
| Kotlin-specific issue from this chapter | MASVS control group | What to verify |
|---|---|---|
Data-class toString writing tokens to logcat |
MASVS-STORAGE |
No sensitive data reaches system logs or crash reports |
Secrets held in by lazy delegates or companion object constants |
MASVS-CRYPTO, MASVS-STORAGE |
Keys are not hardcoded and are not recoverable from the DEX or from memory |
!! on Intent extras in exported components |
MASVS-PLATFORM |
IPC input is validated before use; components are not crashable by third-party apps |
| Platform types from Java or JNI used as non-null | MASVS-CODE |
External input is validated at the boundary |
| Suspend functions performing network work without pinning or validation | MASVS-NETWORK |
Transport security is enforced regardless of which dispatcher the call runs on |
Intrinsics strings and @Metadata leaking original names in a release build |
MASVS-RESILIENCE |
Obfuscation configuration matches the app's threat model |
| Personal data flowing through flows and continuations into logs | MASVS-PRIVACY |
Data minimisation and no incidental persistence |
7. Books¶
- Kotlin in Action, Dmitry Jemerov and Svetlana Isakova, Manning — the standard book for Java developers; chapters on lambdas, inline functions, and Java interop are directly relevant to reading decompiled output. A second edition co-authored with Roman Elizarov and Sebastian Aigner adds coroutines and flows.
- Atomic Kotlin, Bruce Eckel and Svetlana Isakova — small self-contained lessons, well suited to a reader who has never programmed before.
- Effective Kotlin, Marcin Moskała — idioms and their costs; useful for predicting what a well-written codebase looks like and therefore what an anomaly looks like.
- Kotlin Coroutines: Deep Dive, Marcin Moskała — the most thorough treatment of the continuation and state-machine transformation outside the KEEP document.
- Android Security Internals, Nikolay Elenkov, No Starch Press — the platform-security background this repository assumes; predates Kotlin but the runtime and IPC material is unchanged.
- The Mobile Application Hacker's Handbook, Chell, Erasmus, Colley, and Whitehouse, Wiley — assessment methodology to hang the Kotlin-specific techniques on.
8. Talks and long-form articles¶
Conference-talk URLs move between hosting platforms, so these are named rather than linked; each is findable by title on the KotlinConf and JetBrains channels.
- Roman Elizarov, Deep Dive into Coroutines on JVM (KotlinConf) — the talk that walks through the compiler's state-machine transformation with real bytecode; the closest thing to a video version of this chapter's coroutine section.
- Roman Elizarov, Structured Concurrency (article series) — the argument for scoping every coroutine, and the reasoning behind
coroutineScopeandsupervisorScope. - Roman Elizarov, Blocking Threads, Suspending Coroutines (article) — the clearest short explanation of why a suspended coroutine occupies no thread.
- Andrey Breslav and later JetBrains language-design talks on Why Kotlin looks the way it does — the pragmatic trade-offs behind platform types and interop.
- Jake Wharton's talks on Kotlin's generated code and on multiplatform — consistently focused on what the compiler actually emits rather than on syntax.
- The Talking Kotlin podcast, JetBrains — episodes with the compiler team cover back-end decisions that never appear in user documentation.
9. Chapters in this repository that build on this one¶
- 04 — Java — the language the decompiler outputs; prerequisite for everything here.
- 10 — APK Internals — where
classes.dexlives and how to extract it. - 12 — DEX Internals — the string table format that
detect-kotlin.pywalks. - 13 — ART — how these methods are actually executed and compiled.
- 26 — Intent — the delivery mechanism for the null-safety crash cases described in the FAQ.