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