hermes-windows/first-party/fbjni
Neil Dhar 103f1d323a Use prefab JNI in Hermes
Summary:
Instead of including JNI source code in our repo and statically
linking in parts of JNI, use the prebuilt shared library available
from Maven.

While working on fixing the `Intl.NumberFormat` crash in the GC, I
got multiple weird exceptions with stack traces that didn't line up
with `hermesLog` statements I had added to the code. I eventually
suspected something was wrong with having multiple copies of JNI, and
switching to the shared library from maven resolved the crashes.

Reviewed By: tmikov

Differential Revision: D28791954

fbshipit-source-id: 992bc04428795cc3154a229211c1a6f24add32d6
2021-06-08 13:40:45 -07:00
..
.github Run release on release creation (#48) 2021-02-24 02:10:20 -08:00
cxx Random template fix 2020-10-12 17:09:39 -07:00
docs v0.2.2 2021-03-24 11:33:57 -07:00
gradle Don't create separate distribution for headers (#55) 2021-03-24 10:38:09 -07:00
java/com/facebook/jni Migrate to Maven Central (#47) 2021-02-22 08:44:47 -08:00
manifest Migrate to Maven Central (#47) 2021-02-22 08:44:47 -08:00
scripts Switch CI to use Clang (#28) 2019-12-27 14:15:01 -08:00
test Fix test builds under Windows 2020-09-23 23:02:58 -07:00
.gitignore Set up Maven Snapshot/Bintray integration 2019-08-27 08:19:22 -07:00
CODE_OF_CONDUCT.md Adopt Contributor Covenant 2019-08-29 23:20:34 -07:00
CONTRIBUTING.md Adding Contributing file (#1) 2019-08-28 05:50:48 -07:00
LICENSE Add Apache-2 LICENSE file 2019-08-22 10:26:06 -07:00
README.md Update documentation (#22) 2019-10-28 13:13:44 -07:00
build.gradle Remove the package exclusions (#51) 2021-03-04 06:35:14 -08:00
googletest-CMakeLists.txt.in Fix copyright headers 2019-10-01 10:43:38 -07:00
gradle.properties v0.2.3-SNAPSHOT 2021-03-24 11:33:57 -07:00
gradlew Initial gradle setup 2019-08-22 10:26:05 -07:00
gradlew.bat Initial gradle setup 2019-08-22 10:26:05 -07:00
host.gradle Migrate to Maven Central (#47) 2021-02-22 08:44:47 -08:00
settings.gradle Yearless license header 2019-10-22 17:17:28 -07:00

README.md

fbjni

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;
  }
};

Documentation

License

fbjni is Apache-2 licensed, as found in the LICENSE file.