commit | 568b0129b0a49b0b68392f95f4a8c6f6bf3d9bfa | [log] [tgz] |
---|---|---|
author | Joshua Selbo <jselbo@meta.com> | Tue Mar 28 21:56:35 2023 -0700 |
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | Tue Mar 28 21:56:35 2023 -0700 |
tree | db6d8c2a2bb48c8a1305b88219cc1a2b1fba572a | |
parent | 303646316929436ad2720f4877ac3c177dd1b034 [diff] |
Fix CI Reviewed By: jiawei-lyu Differential Revision: D44491212 fbshipit-source-id: be935b09d77e77fd7640a3c28feea48b0c5584ca
The Facebook JNI helpers library is designed to simplify usage of the Java Native Interface. The helpers were implemented to ease the integration of cross-platform mobile code on Android, but there are no Android specifics in the design. It can be used with any Java VM that supports JNI.
struct JMyClass : JavaClass<JMyClass> { static constexpr auto kJavaDescriptor = "Lcom/example/MyClass;"; // Automatic inference of Java method descriptors. static std::string concatenate( alias_ref<JClass> clazz, // Automatic conversion to std::string. std::string prefix) { // Call methods easily. static const auto getSuffix = clazz->getStaticMethod<JString()>("getSuffix"); // Manage JNI references automatically. local_ref<JString> jstr = getSuffix(clazz); // Automatic exception translation between Java and C++ (both ways). // No need to check exception state after each call. result += jstr->toStdString(); // Automatic conversion from std::string. return result; } };
fbjni is Apache-2 licensed, as found in the LICENSE file.