Daily Tech Briefing
AI 科技速览
每天 5 分钟内学习 AI。获取最新的人工智能新闻,理解其重要性,并学习如何将其应用于您的工作。
MarkTechPost · 2026/7/31 10:32:53
JetBrains Open-Sources KotlinLLM: Smart Macros That Generate Kotlin Source Code at Runtime and Hot-Reload It Through JDI
AI 中文解读
JetBrains最近开源了一个叫KotlinLLM的AI编程工具,最吸引人的地方在于:它能让AI写的代码在程序运行过程中自我修正,不重启就能生效。简单说,这个插件给Kotlin语言增加了一个叫“智能宏”的功能,开发者写一行代码,AI就根据提示自动生成对应的代码逻辑。但它的特殊之处在于,如果程序运行时发现AI生成的逻辑不匹配,插件会自动抓取实时数据、让AI重新生成、然后热更新进正在运行的程序里——整个过程就像给跑着的汽车换发动机零件,不用熄火就能完成。测试数据显示,24个场景全部通过,热更新成功率100%,性能开销仅占1%。不过要留意,JetBrains明确标注这是研究原型而非生产级工具,不适合直接用在正式项目上。对普通人的意义在于,AI编程已从“生成代码”进化到“代码自我进化”阶段,未来软件开发的门槛会进一步降低,AI具备更强的自主迭代能力。
JetBrains Research Open-Sources KotlinLLM. KotlinLLM is an IntelliJ IDEA plugin for Kotlin/JVM projects that adds a language feature called Smart macros. A Smart macro is a regular Kotlin function call whose body is generated Kotlin code. The public API is deliberately small. asLlm<F, T>(from, hint) converts an input of type F into a typed value T, such as a data class, enum, list, or primitive. mockLlm<T>() generates a stateful implementation of an interface T, whose behavior depends on which methods are called on it.
Copy CodeCopiedUse a different Browserval 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 launches through the KotlinLLM run configuration, the plugin scans for asLlm and mockLlm calls, updates generated bootstrap/provider/parser/mock files, launches the run configuration under JDI, and registers breakpoints on generated regenerate hooks. If generated logic does not match a runtime scenario, execution reaches a hook. The plugin captures runtime values and type information from the suspended frame, the LLM agent submits a code update, and the plugin compiles it and redefines the loaded class before retrying the original call.
KotlinLLM targets Kotlin/JVM specifically because the runtime evolution loop depends on JVM class redefinition through JDI.
Explainer: how a Smart macro evolves
The embed below walks the macro API, animates the nine-step runtime loop, and models why covered scenarios stop costing inference calls.
window.addEventListener("message",function(e){if(e.data&&e.data.klmHeight){var f=document.getElementById("klm-frame");if(f&&e.data.klmHeight>200){f.style.height=e.data.klmHeight+"px";}}});
Reported results
On an adapted Spring Petclinic Kotlin project with 18 asLlm call sites, 24 of 24 application scenarios completed after Smart macro evolution, with a 100% hot-reload success rate and compilation/redefinition adding roughly 1% of total runtime overhead. A synthetic “GitHub Beginner Issue Radar” parsed real issue data across 20 repositories and 30k+ issues, reaching about 0.89 recall on ground-truth beginner labels.
Setup requirements
The plugin requires IntelliJ IDEA 2025.2.x, JDK 21, and an OpenAI API key stored in the target project’s .kotlinllm file via Tools > KotlinLLM Settings. It is released under the Apache License 2.0, with runnable examples, the thesis write-up, and the KotlinConf 2026 talk recording in the repository.
Is it deployable?
Not as a production runtime, at least not yet. JetBrains labels KotlinLLM a research prototype, and it is described it as an experimental IntelliJ IDEA plugin. The plugin is experimental, but its output is deployable. Once behavior has been generated, the target project can compile and run that behavior without another LLM request for the same scenario. You ship plain Kotlin, not a model dependency.
Company level: best fit today is R&D groups, platform teams at mid-size to large Kotlin/JVM entities, and startups with tolerance for prototype tooling. Regulated enterprises should treat generated sources as reviewable code, which is exactly how KotlinLLM stores them.
Industries: fintech and banking (heavy JVM/Kotlin estates), developer tooling, e-commerce, logistics, and any team parsing messy third-party API payloads.
Applications: normalizing semi-structured API responses into typed values, building evolving test doubles, adapting to upstream schema drift, and classification over noisy text fields.
Key Takeaways
KotlinLLM is a JetBrains Research prototype, not a production runtime.
Smart macros generate Kotlin source that is committed, reviewed, and run without the plugin.
Covered scenarios trigger no further LLM call, so no added latency or cost.
Petclinic evaluation: 24/24 sc
分享
阅读原文 ↗