diff options
author | Sven Gothel <[email protected]> | 2020-09-15 00:14:37 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-09-15 00:14:37 +0200 |
commit | e5581b8781ac501c54721a60006eb8aa02d978ca (patch) | |
tree | 5bb48e80f7b4394b2a253ef6db7cbd673652c3b4 /java | |
parent | 1933103313ac871042a4e350a6d045156431df0c (diff) |
C++ noexcept: JNIMem* (convert exception in dtor to abort)
Diffstat (limited to 'java')
-rw-r--r-- | java/jni/JNIMem.cxx | 16 | ||||
-rw-r--r-- | java/jni/JNIMem.hpp | 20 |
2 files changed, 19 insertions, 17 deletions
diff --git a/java/jni/JNIMem.cxx b/java/jni/JNIMem.cxx index 250cac4e..5ca11baa 100644 --- a/java/jni/JNIMem.cxx +++ b/java/jni/JNIMem.cxx @@ -29,6 +29,7 @@ #include <cstdio> #include "JNIMem.hpp" +#include "dbt_debug.hpp" // #define VERBOSE_ON 1 #ifdef VERBOSE_ON @@ -96,7 +97,7 @@ void JNIEnvContainer::detach() { needsDetach = false; } -JNIGlobalRef::JNIGlobalRef() { +JNIGlobalRef::JNIGlobalRef() noexcept { this->object = nullptr; DBG_PRINT("JNIGlobalRef::def_ctor nullptr"); } @@ -116,7 +117,7 @@ JNIGlobalRef::JNIGlobalRef(const JNIGlobalRef &o) { object = jni_env->NewGlobalRef(o.object); DBG_PRINT("JNIGlobalRef::copy_ctor %p -> %p", o.object, object); } -JNIGlobalRef::JNIGlobalRef(JNIGlobalRef &&o) +JNIGlobalRef::JNIGlobalRef(JNIGlobalRef &&o) noexcept : object(o.object) { DBG_PRINT("JNIGlobalRef::move_ctor %p (nulled) -> %p", o.object, object); o.object = nullptr; @@ -136,18 +137,19 @@ JNIGlobalRef& JNIGlobalRef::operator=(const JNIGlobalRef &o) { DBG_PRINT("JNIGlobalRef::copy_assign %p -> %p", o.object, object); return *this; } -JNIGlobalRef& JNIGlobalRef::operator=(JNIGlobalRef &&o) { +JNIGlobalRef& JNIGlobalRef::operator=(JNIGlobalRef &&o) noexcept { object = o.object; DBG_PRINT("JNIGlobalRef::move_assign %p (nulled) -> %p", o.object, object); o.object = nullptr; return *this; } -JNIGlobalRef::~JNIGlobalRef() { +JNIGlobalRef::~JNIGlobalRef() noexcept { try { JNIEnv * env = *jni_env; if( nullptr == env ) { - throw direct_bt::RuntimeException("JNIGlobalRef dtor null JNIEnv", E_FILE_LINE); + ERR_PRINT("JNIGlobalRef dtor null JNIEnv"); + abort(); } DBG_PRINT("JNIGlobalRef::dtor %p", object); if( nullptr != object ) { @@ -159,12 +161,12 @@ JNIGlobalRef::~JNIGlobalRef() { } } -void JNIGlobalRef::clear() { +void JNIGlobalRef::clear() noexcept { DBG_PRINT("JNIGlobalRef::clear %p (nulled) -> null", object); object = nullptr; } -bool JNIGlobalRef::operator==(const JNIGlobalRef& rhs) const { +bool JNIGlobalRef::operator==(const JNIGlobalRef& rhs) const noexcept { if( &rhs == this ) { DBG_PRINT("JNIGlobalRef::== true: %p == %p (ptr)", object, rhs.object); return true; diff --git a/java/jni/JNIMem.hpp b/java/jni/JNIMem.hpp index 03ec4948..ac6cf11c 100644 --- a/java/jni/JNIMem.hpp +++ b/java/jni/JNIMem.hpp @@ -84,34 +84,34 @@ public: } /* Creates a GlobalRef using a nullptr for API convenience, lazy assignment. */ - JNIGlobalRef(); + JNIGlobalRef() noexcept; /* Creates a GlobalRef from an object passed to it */ JNIGlobalRef(jobject object); JNIGlobalRef(const JNIGlobalRef &o); - JNIGlobalRef(JNIGlobalRef &&o); + JNIGlobalRef(JNIGlobalRef &&o) noexcept; JNIGlobalRef& operator=(const JNIGlobalRef &o); - JNIGlobalRef& operator=(JNIGlobalRef &&o); + JNIGlobalRef& operator=(JNIGlobalRef &&o) noexcept; /* Deletes the stored GlobalRef */ - ~JNIGlobalRef(); + ~JNIGlobalRef() noexcept; /** Clears the java reference, i.e. nulling it, without deleting the global reference via JNI. */ - void clear(); + void clear() noexcept; /* Provides access to the stored GlobalRef as an jobject. */ - jobject operator*() { return object; } + jobject operator*() noexcept { return object; } /* Provides access to the stored GlobalRef as an jobject. */ - jobject getObject() const { return object; } + jobject getObject() const noexcept { return object; } /* Provides access to the stored GlobalRef as a jclass. */ - jclass getClass() const { return (jclass)object; } + jclass getClass() const noexcept { return (jclass)object; } - bool operator==(const JNIGlobalRef& rhs) const; + bool operator==(const JNIGlobalRef& rhs) const noexcept; - bool operator!=(const JNIGlobalRef& rhs) const + bool operator!=(const JNIGlobalRef& rhs) const noexcept { return !( *this == rhs ); } }; |