dropbox / djinni

A tool for generating cross-language type declarations and interface bindings.
Apache License 2.0
2.88k stars 487 forks source link

`noexcept` in `jniDefaultSetPendingFromCurrent` #377

Closed jonmcclung closed 6 years ago

jonmcclung commented 6 years ago

I get the following error when trying to run make example_android. I have made the following changes to Application.mk: NDK_TOOLCHAIN_VERSION := clang APP_PLATFORM := android-23 APP_STL := c++_shared I am using the r17b NDK toolchain, because GCC is deprecated and will be removed next iteration. It should be noted that if I change NDK_TOOLCHAIN_VERSION back to 4.9, everything builds fine.

[arm64-v8a] Compile++      : djinni_jni <= djinni_support.cpp
../../../support-lib/jni/djinni_support.cpp:591:9: error: 'jniDefaultSetPendingFromCurrent' has a non-throwing exception specification but can still throw [-Werror,-Wexceptions]
        throw;
        ^
../../../support-lib/jni/djinni_support.cpp:588:6: note: function declared non-throwing here
void jniDefaultSetPendingFromCurrent(JNIEnv * env, const char * /*ctx*/) noexcept {
     ^                                                                   ~~~~~~~~
1 error generated.

It seems that the jniDefaultSetPendingFromCurrent function in djinni_support.cpp is marked noexcept, yet it still throws:

void jniDefaultSetPendingFromCurrent(JNIEnv * env, const char * /*ctx*/) noexcept {
    assert(env);
    try {
        throw;
    } catch (const jni_exception & e) {
        e.set_as_pending(env);
        return;
    } catch (const std::exception & e) {
        env->ThrowNew(env->FindClass("java/lang/RuntimeException"), e.what());
    }

    // noexcept will call terminate() for anything not caught above (i.e.
    // exceptions which aren't std::exception subclasses).
}
artwyman commented 6 years ago

See discussion on PR #367

artwyman commented 6 years ago

Fixed in #378