Stop dynamically changing Int.JNIType based on the target#16
Stop dynamically changing Int.JNIType based on the target#16sidepelican wants to merge 1 commit intoswiftlang:mainfrom
Int.JNIType based on the target#16Conversation
|
I also feel like this is incorrect, but I wonder if a better solution might be to simply not have Would anything break today if we removed the |
|
My project AndroidKit uses Int for a lot of generated code. |
Can you point to some examples? In https://github.com/PureSwift/Android I mostly see explicit |
|
Not supporting On the contrary, does widening to |
|
I think removing That said, I’m also curious about what specific scenarios would make it fatal for |
If I were to (unwisely) bridge |
|
If the return value of In the case of |
Currently,
Int.JNITypechanges its definition based on the build target's bit width:While this might seem like the correct way to match Swift's
Intsize, I believe this approach is actually incorrect.JNITypeis simply an interface for JNI communication; it doesn't strictly require an exact bit-width match with the native type.In
swift-java,Intis effectively handled asInt64in all JNI interactions.This is because the generated Java source code does not change based on the target architecture, so we must use the wider integer type to ensure consistency.
Using a dynamic
JNITypehas been a frequent source of bugs during type conversion. Therefore, I propose thatInt.JNITypeshould always bejlong.