JetBrains Research has open-sourced KotlinLLM, an IntelliJ IDEA plugin designed for Kotlin/JVM projects. The plugin introduces a language feature called "smart macros," which are regular Kotlin function calls that generate Kotlin source code at runtime. The public API is intentionally minimal, with two core functions: asLlm, which converts an input of type F into a typed value T (such as a data class, enum, list, or primitive), and mockLlm, which generates a stateful implementation of an interface T, with behavior that adapts based on the methods invoked.
Here is an example of smart macros in action:
val issuesApiUrl: String = asLlm(repoInput, hint = "GitHub API URL: get all issues, including closed")
val issues: List<Issue> = asLlm(response, hint = "Return all beginner-friendly issues for this repository")
The Runtime Loop
When a project is launched through the KotlinLLM run configuration, the plugin performs the following steps:
- Scans for
asLlmandmockLlmcalls in the codebase. - Updates generated bootstrap, provider, parser, and mock files accordingly.
- Launches the run configuration under the Java Debug Interface (JDI).
- Registers breakpoints on the generated regeneration hooks.
If the generated logic fails to handle a runtime scenario, execution reaches one of these hooks. At that point, the plugin captures runtime values and type information from the suspended frame, sends the data to an LLM agent for a code update, compiles the updated code, and redefines the loaded class before retrying the original call.
KotlinLLM is particularly valuable for developers who need rapid iteration on AI-generated code, as it enables real-time adaptation without manual restarts. In 2026, with the growing adoption of AI-assisted development tools, KotlinLLM fills a critical niche by bridging the gap between LLM-generated code and the dynamic execution environment of the JVM.
via MarkTechPost
