diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-05 20:41:25 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-05 20:41:25 +0100 |
| commit | aefb3dbf687b46775bca1b600317bc053648b211 (patch) | |
| tree | fc20afdc03ee7cd60bb7fa7bae438fcad033fa5a /stubs/src/kotlin/proxy/KotlinProxyLog.java | |
| parent | a22e0810f6473ff9063166f75b7e4e0236324b6b (diff) | |
First steps for overrides
Diffstat (limited to 'stubs/src/kotlin/proxy/KotlinProxyLog.java')
| -rw-r--r-- | stubs/src/kotlin/proxy/KotlinProxyLog.java | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/stubs/src/kotlin/proxy/KotlinProxyLog.java b/stubs/src/kotlin/proxy/KotlinProxyLog.java index 50e347a..3afdb38 100644 --- a/stubs/src/kotlin/proxy/KotlinProxyLog.java +++ b/stubs/src/kotlin/proxy/KotlinProxyLog.java @@ -51,9 +51,33 @@ public final class KotlinProxyLog { } /** - * Called by stub methods that declare a reference return type (other than - * String). Reflectively instantiates the real, un-stubbed class of that - * return type so the caller (the daemon) can keep going: e.g. + * Return value for stub methods with a reference return type (other than + * String). Asks {@link KotlinProxyOverrides#invoke} first — per-method + * custom implementations, passed the full argument list — and falls back + * to materializing a real no-arg instance of the declared return type. + * The generated body checkcasts the result to the declared type. + * + * The generated bytecode pushes the args array FIRST (member, owner and + * return type last) so its stack stays shallow (peak 4) — keep this + * parameter order in sync with RETURN_VALUE_DESC in gen_class.py. + */ + public static Object returnValue(Object[] args, String member, + String ownerDotName, String returnDotName) { + Object v = KotlinProxyOverrides.invoke(member, ownerDotName, + returnDotName, args); + if (v != KotlinProxyOverrides.NO_VALUE) { + log("OVERRIDE " + ownerDotName + "." + member + + " -> " + dump(v)); + return v; + } + return newInstance(returnDotName); + } + + /** + * Default return-value materialization (the fallback of + * {@link #returnValue}). Reflectively instantiates the real, un-stubbed + * class of the declared return type so the caller (the daemon) can keep + * going: e.g. * K2JVMCompiler.createArguments() returns a genuine K2JVMCompilerArguments, * which lets parseCommandLineArguments run and doExecute be reached with the * fully-populated args (the boundary we want to log). Returns null when the |
