Initial check for invalid JNI method signatures
ClosedPublic

Authored by nicolasfella on Apr 16 2020, 3:34 PM.

Details

Summary

When using QAndroidJniObject to call Android API one needs to specify method signatures using strings. This is error-prone and errors are usually only detected at runtime.
This check searches for a set of known methods that take such signatures and validates them using a regular expression. If a signature is invalid a warning is emitted.

To be able to verify Android-specific code with a desktop clang we need some include path hackery. QAndroidJniObject required jni.h, which is shipped in the Android NDK. We therefore need to amend the include paths. In order to do that we rely on $ANDROID_NDK being set and print an error if not.

Test Plan

Ran tests

Diff Detail

Repository
R74 Clazy
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nicolasfella requested review of this revision.Apr 16 2020, 3:34 PM
nicolasfella created this revision.
smartins requested changes to this revision.Apr 16 2020, 7:12 PM

Each check should have a README (see other checks for an example)
Also add an entry to the ChangeLog

thanks

This revision now requires changes to proceed.Apr 16 2020, 7:12 PM
  • Setup jni include dir when running jni check
  • readme + changelog
nicolasfella edited the summary of this revision. (Show Details)Apr 22 2020, 11:32 AM
nicolasfella planned changes to this revision.Apr 22 2020, 12:26 PM
smartins accepted this revision.Apr 22 2020, 12:43 PM
nicolasfella requested review of this revision.Apr 24 2020, 9:29 AM
This revision is now accepted and ready to land.Apr 24 2020, 9:29 AM
This revision was automatically updated to reflect the committed changes.