macros: Add compile-time checking/inferencing for native method registration
Convert existing NATIVE_METHOD/FAST_NATIVE_METHOD macros into
also checking that the JNI signature descriptor matches the C++ function
type.
For example it matches "(J)V" with "void funcname(JNIEnv*, jclass, jlong)"
with regular native methods.
Also add several new macros:
MAKE_JNI_[FAST_|CRITICAL_]NATIVE_METHOD - Non-convention-requiring macro.
MAKE_JNI_[FAST_|CRITICAL_]NATIVE_METHOD_AUTOSIG - Infer signature for above.
[FAST_|CRITICAL_]NATIVE_METHOD_AUTOSIG - Convention-requiring signature inferencing.
All of the checking/inferencing is done purely at compile time and has
zero runtime cost. If any of the checks fail there will be a compilation
error with a stack trace pointing to the reason.
See jni_macros.h for exact details on check/inference rules.
Bug: 35325126
Change-Id: I98797727ca80caf7bc462582f582b23701a1b661
Test: make -j32 JniSafeRegisterNativeMethods_test \
&& out/host/linux-x86/nativetest64/JniSafeRegisterNativeMethods_test/JniSafeRegisterNativeMethods_test
Test: make -j32 # build all of android, then see if it boots.
4 files changed