diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-05 21:18:56 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-05 21:18:56 +0100 |
| commit | 64223f61fc8413ad69ba0e814fbbc552a6c57c33 (patch) | |
| tree | 79f47335e71dfe6d702fbca520513b2b7eb90fae /CLAUDE.md | |
| parent | aefb3dbf687b46775bca1b600317bc053648b211 (diff) | |
Pass the receiver instance to KotlinProxyOverrides.invoke
The generated returnValue call now carries the stub instance the method
was called on (null for statics), so overrides can keep per-compiler
state instead of statics: the performance manager is now stored in an
IdentityHashMap keyed by receiver, and OVERRIDE log lines carry the
receiver's identityHashCode as inst=0x… .
Diffstat (limited to 'CLAUDE.md')
| -rw-r--r-- | CLAUDE.md | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -25,6 +25,8 @@ table). Read it before changing generation behavior. stub calls into. - `stubs/src/kotlin/proxy/KotlinProxyOverrides.java` — per-method custom return values: the extension point for actually *implementing* stub methods. +- `stubs/src/kotlin/proxy/ProxyPerformanceManager.java` — override support + class (per-compiler-instance perf manager) returned by the overrides. - `jars/defs.txt`, `jars/scan.txt`, `jars/fallback.txt` — jar list files feeding the generator (one jar path per line, `#` = comment). - `dist/kotlin-proxy-compiler-stubs.jar` — the build artifact (gitignored). @@ -46,14 +48,16 @@ python3 tools/gen_class.py \ javac -nowarn -proc:none -d stubs/classes_min \ -cp "$(grep -v '^[[:space:]]*#' jars/defs.txt | tr '\n' ':')" \ stubs/src/kotlin/proxy/KotlinProxyLog.java \ - stubs/src/kotlin/proxy/KotlinProxyOverrides.java + stubs/src/kotlin/proxy/KotlinProxyOverrides.java \ + stubs/src/kotlin/proxy/ProxyPerformanceManager.java # 3. Package jar cf dist/kotlin-proxy-compiler-stubs.jar -C stubs/classes_min . ``` -The result is 5 class files + manifest: the three seeded stubs plus -`kotlin/proxy/KotlinProxyLog` and `kotlin/proxy/KotlinProxyOverrides`. The +The result is 6 class files + manifest: the three seeded stubs plus +`kotlin/proxy/KotlinProxyLog`, `kotlin/proxy/KotlinProxyOverrides`, and +`kotlin/proxy/ProxyPerformanceManager`. The seed trio are **the only** classes stubbed (the "trio" mode); their superclasses/interfaces (`CLICompiler`, `K2JVMCompilerArguments`, …) are *not* stubbed and resolve from the real jars on the daemon classpath. @@ -71,8 +75,10 @@ machinery NPEs after calling into the stub). That is the intended state. To confirm the stub actually ran *inside the out-of-process daemon*, read the marker file `/tmp/kotlin-proxy-marker.txt` — a daemon run shows thread names `RMI TCP Connection(N)` and `LOAD …/dist/kotlin-proxy-compiler-stubs.jar` lines. -An `OVERRIDE <owner>.<member> -> <dump>` line shows a -`KotlinProxyOverrides.invoke` implementation supplied the return value. +An `OVERRIDE <owner>.<member> inst=0x… -> <dump>` line shows a +`KotlinProxyOverrides.invoke` implementation supplied the return value +(`inst` is the receiver instance the method was called on — omitted for +statics). The marker path is fixed regardless of the daemon's working dir or missing `-Dkotlin.proxy.log`, so it is the reliable proof. @@ -95,7 +101,9 @@ Sanity-check generated bytecode with `javap -c stubs/classes_min/org/jetbrains/k boxed; `null` when param-less) and ask `KotlinProxyLog.returnValue`, which consults `KotlinProxyOverrides.invoke` first (per-method custom implementations — the hook for actually *implementing* a stub method with - real arguments) and falls back to materializing a *real* instance of the + real arguments and the receiver — the stub instance the method was called + on, `null` for statics — so overrides can keep per-instance state) and + falls back to materializing a *real* instance of the declared return type so the daemon can proceed (e.g. `createArguments()` yields a real `K2JVMCompilerArguments`). Param-less erasure bridges forward to their concrete sibling instead of |
