ffi 2.10: #jni_method_descriptor override precedence in deriveMethod
When a `ForeignMethodDecl` carries a non-null `jni_descriptor_override` (parsed in step 2.6), `deriveMethod` short-circuits — auto-derivation is skipped entirely and the override is returned (duplicated through the caller's allocator so ownership semantics stay uniform regardless of which branch ran). Two new tests: override beats normal derivation, and override bypasses cross-class refs that would otherwise fail with `UnknownClassAlias`. Confirms the escape-hatch semantics from 2.6 — users can paste an explicit JNI signature when auto-derivation doesn't match (synthetic methods, ambiguous overloads, unknown-to-sx JVM internals). 15 jni_descriptor tests pass; 126/126 examples still green.
This commit is contained in:
@@ -105,6 +105,13 @@ pub fn deriveMethod(
|
||||
ctx: Context,
|
||||
method: ast.ForeignMethodDecl,
|
||||
) DeriveError![]u8 {
|
||||
// `#jni_method_descriptor("(Sig)Ret")` short-circuits derivation
|
||||
// entirely. Allocate a copy so the caller has uniform ownership
|
||||
// semantics regardless of which branch ran.
|
||||
if (method.jni_descriptor_override) |override| {
|
||||
return allocator.dupe(u8, override);
|
||||
}
|
||||
|
||||
var buf: std.ArrayList(u8) = .empty;
|
||||
errdefer buf.deinit(allocator);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user