Files
sx/examples/ffi-jni-call-09-static.sx
agra 814eee1480 ffi 1.23: lock in undef shape for #jni_static_call
Test-add for static dispatch — `#jni_static_call(s32)(env, cls,
"max", "(II)I", 3, 7)` exercises GetStaticMethodID + CallStaticIntMethod
plus two integer args. Today the lowering bails on `is_static = true`
with `LLVMGetUndef`. IR snapshot captures the placeholder.

The next commit:
- Adds `Jni.GetStaticMethodID` (113), `Jni.CallStaticVoidMethod` (141),
  `Jni.CallStaticIntMethod` (129), etc. to the constants struct.
- Wires the static path: skip `GetObjectClass` (`target` IS the
  jclass), `NewGlobalRef(target)` to cache it, `GetStaticMethodID`
  for the method, then `CallStatic<Type>Method` per return type.
2026-05-19 22:40:47 +03:00

23 lines
670 B
Plaintext

// Phase 1 step 1.23 (PLAN-FFI.md): `#jni_static_call` lowering.
// For static dispatch the `target` arg IS already a `jclass`, so the
// lowering skips `GetObjectClass` and uses `GetStaticMethodID` +
// `CallStatic<Type>Method` instead. Today `is_static = true` drops
// to `LLVMGetUndef`; the snapshot captures the placeholder. Next
// commit wires the static dispatch path.
#import "modules/std.sx";
g_should_call : bool = false;
call_static_max :: (env: *void, cls: *void) -> s32 {
#jni_static_call(s32)(env, cls, "max", "(II)I", 3, 7);
}
main :: () -> s32 {
if g_should_call {
_ := call_static_max(null, null);
}
print("ok\n");
0;
}