Merge remote-tracking branch 'origin/upstream' am: d7c1b84a31 am: b5aa70bc6e

Original change: undetermined

Change-Id: Ibb1316a529c1604f81abe92128fd3aabc40db10f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
tree: 277907102de1c1514b4cf06bd1c076eb051f4abc
  1. .github/
  2. cxx/
  3. docs/
  4. gradle/
  5. java/
  6. scripts/
  7. test/
  8. .gitignore
  9. Android.bp
  10. build.gradle
  11. CMakeLists.txt
  12. CODE_OF_CONDUCT.md
  13. CONTRIBUTING.md
  14. googletest-CMakeLists.txt.in
  15. gradle.properties
  16. gradlew
  17. gradlew.bat
  18. host.gradle
  19. LICENSE
  20. METADATA
  21. MODULE_LICENSE_APACHE2
  22. OWNERS
  23. PREUPLOAD.cfg
  24. README.md
  25. settings.gradle
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.