You know how to use Kotlin, but do you know the advanced features? What are the consequences of using variance modifiers? What limitations do they introduce, and how can these be overcome? How does property delegation work? How to use reflection? How to implement a KSP or an annotation processor? How is a Kotlin Compiler Plugin implemented? If you want to know the answers to these questions, this book is for you.
About the book
This book focuses on the advanced aspects of Kotlin's development. These are often features and tools that developers use daily, even though they don’t know exactly how they work. This book explains them and gives you the knowledge to use these features in your projects.
Who this book is for
This book is for developers with Kotlin experience who want to learn about its advanced features. Readers are expected to have experience in Kotlin development. All the required knowledge can be discovered in the books Kotlin Essentials and Functional Kotlin.
What is covered
This book focuses on advanced Kotlin features, including:
Generic variance modifiers
Interface and property delegation
Kotlin Contracts
Kotlin and Java interoperability
Multiplatform development
Using Kotlin/JS
Kotlin reflection
Annotation Processor
Kotlin Symbol Processor
Kotlin Compiler Plugins
Static Analysis with custom rules
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A practical deep-dive into the Kotlin features you already use but may not fully understand—variance, delegation, contracts, Java interop, multiplatform, reflection, and the processor/compiler-plugin toolchain. Best for experienced Kotlin developers who want to reason about consequences and build tooling, not just write app code.
【Book Arc】
- **Opening (~0%–10%)**: Sets scope and prerequisites, then moves into generic variance—why `in`/`out` exist, what they forbid, and how `UnsafeVariance` and star projections work around those limits.
- **Early (~10%–32%)**: Delegation as a design tool: interface and property delegation, how delegates compile to accessor code, and the standard `lazy`, `Lateinit`, and `vetoable` delegates with their trade-offs.
- **Early–Middle (~32%–42%)**: Kotlin Contracts as compiler hints (`returns`, `implies`, `callsInPlace`), followed by Kotlin–Java interop: nullability annotations, annotation targets, `@JvmName`/`@JvmOverloads`, and `fun interface`.
- **Middle (~42%–48%)**: Multiplatform structure—shared modules, source sets, expect/actual, and using shared code from Java, JS, and native targets.
- **Late (~48%–65%)**: Reflection and metaprogramming: breaking encapsulation, then building annotation processors and KSP processors, including testing, dependencies, incremental and multi-round processing.
- **Ending (~65%–100%)**: Compiler plugins (frontend/backend, extensions, examples like making classes open or generating wrappers) and static analysis with custom detekt rules, closing with exercises and solutions.
【Key Takeaways】
- **Variance modifiers carry real consequences** (Opening): `in`/`out` are not decoration—they restrict where type parameters may appear, and the book shows the workarounds (`UnsafeVariance`, star projections, `Nothing`) and when they are legitimate.
- **Delegation beats inheritance for composition** (Early): you can delegate to many objects but inherit from one; inheritance is a strong, encapsulation-breaking relationship, so delegation is often the safer default.
- **Property delegates are just generated accessors** (Early): understanding the compiled `getValue`/`setValue` shape explains receiver types, `KProperty` access, and why `ReadWriteProperty<Any?, T>` is the usual contract.
- **Standard delegates have hidden knobs** (Early): `lazy` thread-safety modes trade speed for safety; `vetoable` validates state changes; `Lateinit` shows how to build your own delegate.
- **Contracts make the compiler smarter** (Early): `returns(false) implies (...)` and `callsInPlace` enable smart casts and non-local returns that would otherwise be impossible—worth knowing when writing inline APIs.
- **Interop friction is structural, not accidental** (Middle): nullability annotations, platform types, annotation targets, and default arguments all need explicit handling; `fun interface` fixes Java call-site ergonomics.
- **Multiplatform is about source-set layout** (Middle): shared modules and correctly named source sets let one library serve JVM, JS, and native consumers.
- **Tooling is a ladder** (Late–Ending): reflection → annotation processing → KSP → compiler plugins → static analysis; each step trades simplicity for power and build complexity.
【Reading Tips】
- Deep-read the variance and delegation chapters; they underpin later material and repay re-reading with the exercises.
- Skim the interop chapter if you work purely in Kotlin, but keep the annotation-target and `@JvmOverloads` sections as reference.
- Treat the processor/KSP/compiler-plugin chapters as hands-on: build the smallest working example before reading the advanced sections on rounds and incremental processing.
- Do the end-of-chapter exercises—solutions are included—especially the serialization and DI-library ones, which consolidate reflection and DSL skills.
- Use the detekt chapter as a practical entry point to static analysis even if you never write a compiler plugin.
【Coverage Limits】
The excerpts cover the table of contents and sampled sections on variance, delegation, contracts, interop, multiplatform, reflection, processors, compiler plugins, and detekt; Kotlin/JS specifics and several exercise details are only partially represented, so this guide does not assess their depth.
Page 7
rounds processing 302 Using KSP onmultiplatformprojects 305 Summary 306 Exercise: Kotlin Symbol Processing 306 Kotlin Compiler Plugins 308 Compiler frontend...
on(user: User): Boolean fun showOnPage(page: Page): Boolean fun showOnArticle(article: Article): Boolean } class ShowOnPerson( val authorKey: String, val pre...
efinitelyworth all the amazing features that Kotlin offers. Exercise: Adjust Kotlin for Java usage Consider the following Kotlin elements: ²¹Java’s first sta...
efix.This indicates that this type ispartofKotlinReflection and differentiates these classes from Java Reflection. The type Class is part of Java Reflection,...
s are similar.We can transformbetween these two hierarchies using extension properties accessible on Kotlin/JVM. For ex- ample, we can use the java property...
Kotlin Compiler can use plugins that change its behavior.We define a Kotlin Compiler plugin by extending a special class, called an extension, and then regis...
ated logger and want to ensure all logging goes through it. Your inspector can ask to visit all the nodes in your AST that are of type “function call”. On th...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Advanced Kotlin (Marcin Moskała)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
Advanced Kotlin (Marcin Moskała)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Advanced Kotlin (Marcin Moskała)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment