[Development] Make Qt6 JNI API safer to use
Bogdan Vatra
bogdan.vatra at kdab.com
Thu Mar 5 16:59:51 CET 2020
Hi,
În ziua de joi, 5 martie 2020, la 17:14:44 EET, Vitaly Fanaskov a scris:
> I think something like std::expected is a nice thing to have.
>
> There is some experimental implementation of std::expected:
> https://github.com/TartanLlama/expected.
>
That implementation is my favorite, I really like the map, map_error,
and_then, or_else additions ;-) .
[...]
>
> Regarding using exceptions, well, I would vote for this option, but I
> don't think that this is possible at all to convince people to use
> exceptions in this module.
>
A single Qt JNI call might fail in different places, e.g.:
auto str1 = QAndroidJniObject::callStaticObjectMethod("MyClass",
"fromNumber",
"(I)Ljava/lang/String;",
10);
1. check if there is any pending exceptions on current JNI Env
2. check if the method signature is okay
3. check if the method call throw any exceptions
Using exceptions we can pinpoint what happened.
Imagine how hard will be without exceptions to pass as parameters more jni
methods/fields results ...
Cheers,
BogDan.
More information about the Development
mailing list