Skip to content

jextract: implement Java-side integer overflow checks for FFM (#517)#549

Merged
ktoso merged 5 commits intoswiftlang:mainfrom
DPrakashhh:feature/jextract-overflow-check-517
Mar 18, 2026
Merged

jextract: implement Java-side integer overflow checks for FFM (#517)#549
ktoso merged 5 commits intoswiftlang:mainfrom
DPrakashhh:feature/jextract-overflow-check-517

Conversation

@DPrakashhh
Copy link
Contributor

This PR implements integer overflow checks for FFM mode (Issue #517). I have performed a hard reset to ensure a surgical implementation with zero unrelated formatting changes, addressing your previous feedback.

Key Updates:

1-Architectural Alignment: Added SwiftValueLayout.has32bitSwiftInt to gate architecture-specific checks, matching the project's JNI patterns.

Verified: All 207 tests passed successfully.

Supersedes PR #546.

@ktoso — Please don't worry about this until you're feeling better. Wishing you a speedy recovery! :)

@DPrakashhh DPrakashhh requested a review from ktoso as a code owner February 3, 2026 01:59
@DPrakashhh
Copy link
Contributor Author

I’ve refined the overflow logic to distinguish between signed Int and unsigned UInt ranges. I thought this would provide better robustness and architectural parity with the existing JNI implementation, ensuring that 0xFFFFFFFFL is correctly handled for unsigned types while standard integer bounds apply to signed ones. :)

@ktoso
Copy link
Collaborator

ktoso commented Mar 18, 2026

Hi there, sorry that I was slow to respond here in February -- coming back to this now, I'll see to the conflicts and review the change.

DPrakashhh and others added 3 commits March 18, 2026 15:26
…efactor duplication

- Add String message constructor to SwiftIntegerOverflowException (fixes compilation error)
- Rename swiftArena$ to swiftArena to match main branch convention
- Extract printReturnWithOverflowCheck helper to reduce code duplication
@ktoso ktoso force-pushed the feature/jextract-overflow-check-517 branch from 03b1440 to d9f4916 Compare March 18, 2026 08:35
@ktoso
Copy link
Collaborator

ktoso commented Mar 18, 2026

LGTM, thank you! Sorry again reviewing took me a while, now being more responsive -- if you'd like to tackle something else!

Edits: Just adjusted code a little bit around the printing, so that we don't have that much repeated print() around.

@ktoso ktoso merged commit b714888 into swiftlang:main Mar 18, 2026
61 checks passed
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