diff --git a/build.gradle b/build.gradle index 15d47e6..37bf5fe 100644 --- a/build.gradle +++ b/build.gradle @@ -87,7 +87,7 @@ android { dependencies { compileOnly 'com.google.code.findbugs:jsr305:3.0.2' - implementation 'com.facebook.soloader:nativeloader:0.10.1' + api 'com.facebook.soloader:nativeloader:0.10.1' } apply from: rootProject.file('gradle/release.gradle') diff --git a/cxx/fbjni/detail/CoreClasses.h b/cxx/fbjni/detail/CoreClasses.h index 551f766..7cc599b 100644 --- a/cxx/fbjni/detail/CoreClasses.h +++ b/cxx/fbjni/detail/CoreClasses.h @@ -607,6 +607,36 @@ class JThrowable : public JavaClass { void setStackTrace(alias_ref>); }; +class JRuntimeException : public JavaClass { + public: + static auto constexpr kJavaDescriptor = "Ljava/lang/RuntimeException;"; + + static local_ref create(const char* str); + + static local_ref create(); +}; + +class JIOException : public JavaClass { + public: + static auto constexpr kJavaDescriptor = "Ljava/io/IOException;"; + + static local_ref create(const char* str); +}; + +class JOutOfMemoryError : public JavaClass { + public: + static auto constexpr kJavaDescriptor = "Ljava/lang/OutOfMemoryError;"; + + static local_ref create(const char* str); +}; + +class JArrayIndexOutOfBoundsException : public JavaClass { + public: + static auto constexpr kJavaDescriptor = "Ljava/lang/ArrayIndexOutOfBoundsException;"; + + static local_ref create(const char* str); +}; + #pragma push_macro("PlainJniRefMap") #undef PlainJniRefMap #define PlainJniRefMap(rtype, jtype) \ diff --git a/cxx/fbjni/detail/Exceptions.cpp b/cxx/fbjni/detail/Exceptions.cpp index c697adb..6fd622b 100644 --- a/cxx/fbjni/detail/Exceptions.cpp +++ b/cxx/fbjni/detail/Exceptions.cpp @@ -39,46 +39,6 @@ namespace facebook { namespace jni { namespace { -class JRuntimeException : public JavaClass { - public: - static auto constexpr kJavaDescriptor = "Ljava/lang/RuntimeException;"; - - static local_ref create(const char* str) { - return newInstance(make_jstring(str)); - } - - static local_ref create() { - return newInstance(); - } -}; - -class JIOException : public JavaClass { - public: - static auto constexpr kJavaDescriptor = "Ljava/io/IOException;"; - - static local_ref create(const char* str) { - return newInstance(make_jstring(str)); - } -}; - -class JOutOfMemoryError : public JavaClass { - public: - static auto constexpr kJavaDescriptor = "Ljava/lang/OutOfMemoryError;"; - - static local_ref create(const char* str) { - return newInstance(make_jstring(str)); - } -}; - -class JArrayIndexOutOfBoundsException : public JavaClass { - public: - static auto constexpr kJavaDescriptor = "Ljava/lang/ArrayIndexOutOfBoundsException;"; - - static local_ref create(const char* str) { - return newInstance(make_jstring(str)); - } -}; - class JUnknownCppException : public JavaClass { public: static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/UnknownCppException;"; @@ -186,6 +146,22 @@ void JThrowable::setStackTrace(alias_ref stack) { return meth(self(), stack); } +local_ref JRuntimeException::create(const char *str) { + return newInstance(make_jstring(str)); +} +local_ref JRuntimeException::create() { + return newInstance(); +} +local_ref JIOException::create(const char *str) { + return newInstance(make_jstring(str)); +} +local_ref JOutOfMemoryError::create(const char *str) { + return newInstance(make_jstring(str)); +} +local_ref JArrayIndexOutOfBoundsException::create(const char *str) { + return newInstance(make_jstring(str)); +} + auto JStackTraceElement::create( const std::string& declaringClass, const std::string& methodName, const std::string& file, int line) -> local_ref {