diff --git a/cxx/fbjni/detail/CoreClasses-inl.h b/cxx/fbjni/detail/CoreClasses-inl.h index d325e41..156b059 100644 --- a/cxx/fbjni/detail/CoreClasses-inl.h +++ b/cxx/fbjni/detail/CoreClasses-inl.h @@ -304,6 +304,11 @@ inline void registerNatives(const char* name, std::initializer_listregisterNatives(methods); } +inline auto JClass::getCanonicalName() -> local_ref { + static auto meth = javaClassStatic()->getMethod("getCanonicalName"); + return meth(self()); +} + // jstring ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/cxx/fbjni/detail/CoreClasses.h b/cxx/fbjni/detail/CoreClasses.h index 7cd7858..5ff483e 100644 --- a/cxx/fbjni/detail/CoreClasses.h +++ b/cxx/fbjni/detail/CoreClasses.h @@ -37,6 +37,7 @@ namespace jni { class JClass; class JObject; +class JString; namespace detail { @@ -329,6 +330,9 @@ class JClass : public JavaClass { template JNonvirtualMethod getNonvirtualMethod(const char* name, const char* descriptor) const; + /// Get the canonical name of the class + local_ref getCanonicalName(); + private: jclass self() const noexcept; }; @@ -604,6 +608,7 @@ class JThrowable : public JavaClass { local_ref initCause(alias_ref cause); local_ref getStackTrace(); + local_ref getMessage(); void setStackTrace(alias_ref>); }; diff --git a/cxx/fbjni/detail/Exceptions.cpp b/cxx/fbjni/detail/Exceptions.cpp index 22f6327..5e1aa00 100644 --- a/cxx/fbjni/detail/Exceptions.cpp +++ b/cxx/fbjni/detail/Exceptions.cpp @@ -186,6 +186,11 @@ void JThrowable::setStackTrace(alias_ref stack) { return meth(self(), stack); } +auto JThrowable::getMessage() -> local_ref { + static auto meth = javaClassStatic()->getMethod("getMessage"); + return meth(self()); +} + auto JStackTraceElement::create( const std::string& declaringClass, const std::string& methodName, const std::string& file, int line) -> local_ref {