Skip to content

Conversation

@DPrakashhh
Copy link

Description
Summary: This PR aligns FFM mode with JNI by moving integer validation to the Java side. This prevents native crashes by catching out-of-range values before they reach Swift.

Key Changes
1-Java-Side Validation: Moved range checks from native thunks to Java wrappers using a shared ArithmeticException helper.
2-Type Widening: Parameters (e.g., Int8/16/32) are now widened in Java to allow safe bounds checking against Swift's target limits.
3-Unsigned Handling: Added specific checks to bridge the gap between Java's signed types and Swift's UInt types.
4-Updated Tests: Adjusted "golden" expectations for UnsignedNumberTests, MethodImportTests, and others to reflect new safety logic.

Verification
1-Full Suite: All 201 tests passed across 41 suites.
2-Toolchain: Verified on JDK 25 and Swift 6.2.1.

@DPrakashhh DPrakashhh requested a review from ktoso as a code owner January 31, 2026 11:42
@DPrakashhh DPrakashhh marked this pull request as draft January 31, 2026 11:42
@DPrakashhh DPrakashhh force-pushed the feature/jextract-overflow-check-517 branch 2 times, most recently from 9065f02 to e85d9fb Compare February 1, 2026 03:02
@DPrakashhh DPrakashhh closed this Feb 1, 2026
@DPrakashhh DPrakashhh force-pushed the feature/jextract-overflow-check-517 branch from e85d9fb to c586ffc Compare February 1, 2026 03:49
@DPrakashhh DPrakashhh reopened this Feb 1, 2026
@DPrakashhh
Copy link
Author

I’ve updated the logic to use the new SwiftValueLayout.has32bitSwiftInt helper as suggested. I also included some minor formatting/indentation fixes to keep the generated code consistent.

Please let me know if you’d prefer the formatting changes removed; otherwise, the logic is ready for another look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants