• Home
Name Date Size #Lines LOC

..--

.github/04-Jul-2025-8969

cxx/04-Jul-2025-9,5445,957

docs/04-Jul-2025-839720

gradle/wrapper/04-Jul-2025-65

java/com/facebook/jni/04-Jul-2025-644262

scripts/04-Jul-2025-3612

test/04-Jul-2025-6,4394,558

.gitignoreD04-Jul-2025129 86

Android.bpD04-Jul-2025972 4543

CMakeLists.txtD04-Jul-20253.7 KiB117101

CODE_OF_CONDUCT.mdD04-Jul-20253.3 KiB7857

CONTRIBUTING.mdD04-Jul-20251.2 KiB3124

LICENSED04-Jul-202510.5 KiB191160

METADATAD04-Jul-2025652 1918

MODULE_LICENSE_APACHE2D04-Jul-20250

OWNERSD04-Jul-2025123 32

PREUPLOAD.cfgD04-Jul-202528 22

README.mdD04-Jul-20251.5 KiB4335

build.gradleD04-Jul-20252.3 KiB10084

googletest-CMakeLists.txt.inD04-Jul-2025620 2117

gradle.propertiesD04-Jul-20251.1 KiB3530

gradlewD04-Jul-20255.6 KiB186125

gradlew.batD04-Jul-20252.7 KiB9068

host.gradleD04-Jul-20251.5 KiB6254

settings.gradleD04-Jul-2025761 2623

README.md

1# fbjni
2
3The Facebook JNI helpers library is designed to simplify usage of the
4[Java Native Interface](https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/jniTOC.html).
5The helpers were implemented to ease the integration of cross-platform mobile
6code on Android, but there are no Android specifics in the design. It can be
7used with any Java VM that supports JNI.
8
9```cpp
10struct JMyClass : JavaClass<JMyClass> {
11  static constexpr auto kJavaDescriptor = "Lcom/example/MyClass;";
12
13  // Automatic inference of Java method descriptors.
14  static std::string concatenate(
15      alias_ref<JClass> clazz,
16      // Automatic conversion to std::string.
17      std::string prefix) {
18    // Call methods easily.
19    static const auto getSuffix = clazz->getStaticMethod<JString()>("getSuffix");
20    // Manage JNI references automatically.
21    local_ref<JString> jstr = getSuffix(clazz);
22    // Automatic exception translation between Java and C++ (both ways).
23    // No need to check exception state after each call.
24    result += jstr->toStdString();
25    // Automatic conversion from std::string.
26    return result;
27  }
28};
29```
30
31## Documentation
32
33- [Why use a JNI wrapper?](docs/rationale.md)
34- [Set up your Android build with fbjni](docs/android_setup.md)
35- [Quick reference to most features (great for copy/pasting!)](docs/quickref.md)
36- [Internal documentation for maintainers](docs/maintainers.md)
37<!-- TODO: tutorial -->
38<!-- TODO: Comparison with other frameworks. -->
39
40## License
41
42fbjni is Apache-2 licensed, as found in the [LICENSE](/LICENSE) file.
43