Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: package com.facebook.soloader.nativeloader does not exist #59

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
30 changes: 30 additions & 0 deletions cxx/fbjni/detail/CoreClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,36 @@ class JThrowable : public JavaClass<JThrowable, JObject, jthrowable> {
void setStackTrace(alias_ref<JArrayClass<JStackTraceElement::javaobject>>);
};

class JRuntimeException : public JavaClass<JRuntimeException, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/lang/RuntimeException;";

static local_ref<JRuntimeException> create(const char* str);

static local_ref<JRuntimeException> create();
};

class JIOException : public JavaClass<JIOException, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/io/IOException;";

static local_ref<JIOException> create(const char* str);
};

class JOutOfMemoryError : public JavaClass<JOutOfMemoryError, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/lang/OutOfMemoryError;";

static local_ref<JOutOfMemoryError> create(const char* str);
};

class JArrayIndexOutOfBoundsException : public JavaClass<JArrayIndexOutOfBoundsException, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/lang/ArrayIndexOutOfBoundsException;";

static local_ref<JArrayIndexOutOfBoundsException> create(const char* str);
};

#pragma push_macro("PlainJniRefMap")
#undef PlainJniRefMap
#define PlainJniRefMap(rtype, jtype) \
Expand Down
56 changes: 16 additions & 40 deletions cxx/fbjni/detail/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,6 @@ namespace facebook {
namespace jni {

namespace {
class JRuntimeException : public JavaClass<JRuntimeException, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/lang/RuntimeException;";

static local_ref<JRuntimeException> create(const char* str) {
return newInstance(make_jstring(str));
}

static local_ref<JRuntimeException> create() {
return newInstance();
}
};

class JIOException : public JavaClass<JIOException, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/io/IOException;";

static local_ref<JIOException> create(const char* str) {
return newInstance(make_jstring(str));
}
};

class JOutOfMemoryError : public JavaClass<JOutOfMemoryError, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/lang/OutOfMemoryError;";

static local_ref<JOutOfMemoryError> create(const char* str) {
return newInstance(make_jstring(str));
}
};

class JArrayIndexOutOfBoundsException : public JavaClass<JArrayIndexOutOfBoundsException, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Ljava/lang/ArrayIndexOutOfBoundsException;";

static local_ref<JArrayIndexOutOfBoundsException> create(const char* str) {
return newInstance(make_jstring(str));
}
};

class JUnknownCppException : public JavaClass<JUnknownCppException, JThrowable> {
public:
static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/UnknownCppException;";
Expand Down Expand Up @@ -186,6 +146,22 @@ void JThrowable::setStackTrace(alias_ref<JStackTrace> stack) {
return meth(self(), stack);
}

local_ref<JRuntimeException> JRuntimeException::create(const char *str) {
return newInstance(make_jstring(str));
}
local_ref<JRuntimeException> JRuntimeException::create() {
return newInstance();
}
local_ref<JIOException> JIOException::create(const char *str) {
return newInstance(make_jstring(str));
}
local_ref<JOutOfMemoryError> JOutOfMemoryError::create(const char *str) {
return newInstance(make_jstring(str));
}
local_ref<JArrayIndexOutOfBoundsException> 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<javaobject> {
Expand Down