Skip to content

Commit

Permalink
fix: Unwrap boxed JNI types directly (#2337)
Browse files Browse the repository at this point in the history
* fix: Unwrap boxed JNI types directly

* Update JSIJNIConversion.cpp
  • Loading branch information
mrousavy authored Jan 2, 2024
1 parent 3dc7511 commit ef4e9fa
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions package/android/src/main/cpp/frameprocessor/JSIJNIConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,20 @@ jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime& runtime, c
} else if (object->isInstanceOf(jni::JBoolean::javaClassStatic())) {
// Boolean

static const auto getBooleanFunc = jni::findClassLocal("java/lang/Boolean")->getMethod<jboolean()>("booleanValue");
auto boolean = getBooleanFunc(object.get());
return jsi::Value(boolean == true);
auto boxed = static_ref_cast<JBoolean>(object);
bool value = boxed->value();
return jsi::Value(value);
} else if (object->isInstanceOf(jni::JDouble::javaClassStatic())) {
// Double

static const auto getDoubleFunc = jni::findClassLocal("java/lang/Double")->getMethod<jdouble()>("doubleValue");
auto d = getDoubleFunc(object.get());
return jsi::Value(d);
auto boxed = static_ref_cast<JDouble>(object);
double value = boxed->value();
return jsi::Value(value);
} else if (object->isInstanceOf(jni::JInteger::javaClassStatic())) {
// Integer

static const auto getIntegerFunc = jni::findClassLocal("java/lang/Integer")->getMethod<jint()>("intValue");
auto i = getIntegerFunc(object.get());
return jsi::Value(i);
auto boxed = static_ref_cast<JInteger>(object);
return jsi::Value(boxed->value());
} else if (object->isInstanceOf(jni::JString::javaClassStatic())) {
// String

Expand Down

1 comment on commit ef4e9fa

@vercel
Copy link

@vercel vercel bot commented on ef4e9fa Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.