We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

A mirror without reflection for Kotlin/Multiplatform

Formal Metadata

Title
A mirror without reflection for Kotlin/Multiplatform
Title of Series
Number of Parts
542
Author
License
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Reflection is a very powerful JVM feature that allows to create implementations of interfaces on the go, as well as exploring the type hierarchy, methods and properties of a given class. These capabilities do not exist in Kotlin/Multiplatform, so we will explore an alternative method to runtime reflection: a compile-time symbol processor to create compile time mirrors. Using Mocking as an excuse (as mocking typically needs reflection), we will explore how we can use KSP (Kotlin Symbol Processor) to circumvent the absence of reflection and generate efficient test mocks at compile time. We will also see the limitations that multiplatform brings to both the KSP generator and its associated runtime, and we will explain the tradeoff that needs to be made when using KSP, and why they are needed.