Skip to content

A library designed to simplify the usage of the Java Native Interface

License

Notifications You must be signed in to change notification settings

passy/fbjni

This branch is 3 commits ahead of, 112 commits behind facebookincubator/fbjni:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 23, 2021
a195b00 · Feb 23, 2021
Feb 23, 2021
Oct 13, 2020
Feb 23, 2021
Feb 22, 2021
Feb 22, 2021
Feb 22, 2021
Dec 27, 2019
Sep 24, 2020
Aug 27, 2019
Feb 21, 2021
Aug 30, 2019
Aug 28, 2019
Aug 27, 2019
Oct 28, 2019
Feb 22, 2021
Oct 1, 2019
Feb 23, 2021
Aug 27, 2019
Aug 27, 2019
Feb 22, 2021
Oct 23, 2019

Repository files navigation

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.

About

A library designed to simplify the usage of the Java Native Interface

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 80.8%
  • Java 17.1%
  • CMake 1.3%
  • Other 0.8%