Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92952

Improve public JNI API

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • None

    Description

      While porting the QtPositioning android plugin to new public JNI API, I came up with some ideas for the improvement of the API.

      1.  It might be useful to add QJniObject::call*Method overloads that use jmethodID instead of const char *methodName. Some client code (for example the QtPositioning plugin) already caches the method ids, but does not implement proper exception handling. Adding such overloads will reduce the overhead of querying the methods by name. Currently QJniObject implements a caching mechanism, but it uses locks, so using the saved jmethodIDs directly would still be more efficient.
      2. Same as above point but for fields.
      3. Almost the same idea for QJniEnvironment::registerNativeMethods. It uses const char *className, but can also use jclass parameter.
      4. It might make sense to extend the QJniEnvironment constructor with the version parameter. For now JNI_VERSION_1_6 is hardcoded, but what if a newer version is required? We can make JNI_VERSION_1_6 default, but give the user a possibility to override.
      5. Also probably makes sense to add some method to check that the constructed QJniEnvironment is valid. Looking into oracle jni docs makes me think, that we can simply check the native jniEnv pointer. But having a convenience method for that would be nice from our side, because the user would not need to dig into oracle docs.

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              assam Assam Boudjelthia
              ivan.solovev Ivan Solovev
              Vladimir Minenko Vladimir Minenko
              Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes