jextract: Implement Java-side integer overflow checks for FFM mode (#517)#546
jextract: Implement Java-side integer overflow checks for FFM mode (#517)#546DPrakashhh wants to merge 0 commit intoswiftlang:mainfrom
Conversation
9065f02 to
e85d9fb
Compare
e85d9fb to
c586ffc
Compare
|
I’ve updated the logic to use the new Please let me know if you’d prefer the formatting changes removed; otherwise, the logic is ready for another look! Sir, its ready for another look :) |
|
That's a lot of unrelated changes, may I ask if you're using some agent to write these changes? It makes it difficult to review, please try to keep changes committed to a minimum so that that they are easier to review. I ended up sick at a conference just now... I'll review as soon as I'm able to in a few days |
aab3778 to
d087f65
Compare
|
I am closing this PR - ig starting a new one will be better after all this mess :/ Closing this in favor of a fresh, clean PR with the |
d55b35c to
d087f65
Compare
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
ArithmeticExceptionhelper.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
UInttypes.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.