summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qjni.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-06-031-180/+292
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
| * Merge remote-tracking branch 'origin/5.4' into 5.5Liang Qi2015-06-011-180/+292
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/generators/mac/pbuilder_pbx.cpp src/corelib/global/qglobal.h Change-Id: I2c0f7544bf194f2d0f59218fd583c822901487b0
| | * Android: Store and use the class names as key when caching.Christian Strømme2015-05-081-180/+292
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the jclass handle was part of the key used for caching the class' methods and fields. Using the jclass handle is not ideal, but it meant that we could easily create a key when the only identifier we had was the jobject or jclass handle. However, in Android 5.1, the re-use of handles seems to be more aggressive and therefore increasing the chance of a collision in the cache look-up. This change removes caching for all calls where we don't know the class name, as that is the only thing that guarantees that we create unique keys for each class. The consequence of this is that only calls that provide a class name will benefit from the internal caching. Task-number: QTBUG-45748 Change-Id: I0039d04e7c068debc9e3b3983632c45dc8e52309 Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-011-7/+8
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/testlib/qtestblacklist.cpp src/widgets/accessible/qaccessiblewidgets.cpp Change-Id: If032adb9296428f62384ed835dbf41ee7a0b886c
| * | Android: Only take ownership of threads we explicitly attach to.Christian Strømme2015-03-301-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would take ownership of all threads when attempting to attach it to the VM, regardless if it was already attached or not, to avoid expensive re-attachments in our own code. The downside of this approach is that we might hijack threads the user wants to control themselves, and the later detach the thread while it still in use, e.g., after the QApplication instance is destroyed. This change does not add any infrastructure to enable more advanced management of attached threads, so threads might still be hijacked if the user make a call directly or indirectly through the QJNI API's on a thread that's not attached. Task-number: QTBUG-45110 Change-Id: I30f7faa2d8c2c35151e2ac8875ebf839bcd6c7c6 Reviewed-by: Sergey Galin <s.galin@2gis.ru> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* | | Android: Add scoped local ref. handler.Christian Strømme2015-02-261-1/+9
|/ / | | | | | | | | | | | | | | | | | | | | Adds an internal class for handling local jni references. When calling raw jni functions the returned object is usually a local reference, to avoid overflowing the local reference table we need to free any local ref. as soon as we're done with them. The class QJNIScopedLocalRef, a QScopedPointer, makes this process a lot easier. Change-Id: I093e5671f0dcd254d5c2c7985c8c0f625d5592a4 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-241-1/+8
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/xml/htmlinfo/simpleexample.html examples/xml/rsslisting/rsslisting.cpp qmake/generators/win32/msbuild_objectmodel.cpp src/3rdparty/harfbuzz-ng/src/hb-private.hh src/corelib/global/qlogging.cpp src/corelib/io/qstorageinfo_unix.cpp src/corelib/thread/qwaitcondition_unix.cpp src/gui/kernel/qguiapplication.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp src/testlib/doc/src/qt-webpages.qdoc tests/auto/other/qaccessibility/tst_qaccessibility.cpp Change-Id: Ib272ff0bc30a1a5d51275eb3cd2f201dc82c11ff
| * Android: Fix local ref handling.Christian Strømme2015-02-171-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We where allowing conversion from jobject to QJNIObject without taking ownership of the jobject. Since we are managing the JNI environment we should not allow conversions without having the option of taking ownership of the local ref. This is now done by making the conversions explicit, i.e., local refs are converted through QJNIObjectPrivate::fromLocalRef() and global refs through the QJNIObjectPrivate's jobject constructor. This change breaks SC, but the API is private and no usage have been found outside QtBase. Change-Id: I3175f171699ec3f8e65144aaebc6246bc6e5bb4d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* | Update copyright headersJani Heikkinen2015-02-111-7/+7
|/ | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Android: protect global jni cache.Christian Strømme2014-11-211-25/+58
| | | | | | | | | | | This fixes a issue that has been neglected for a while, namely, that the access to the global jni caches where not sufficiently protected for concurrent usage. This change also fixes an issue with the thread-name storage. Task-number: QTBUG-42755 Change-Id: I22f95ae7f44d1f6a13e289e52b050d98ccb9fb28 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Android: Fix for build issue on x86Christian Strømme2014-11-061-124/+124
| | | | | | | | | | | In the toolchain for x86 the va_list type is defined as char *, which in itself isn't strange, but it was somewhat unexpected as it differs from the arm toolchains. Either way we should not make assumption about the va_list type as there is no guarantee it won't cause conflicts when overloading. This fix simply renames the private overloads. Change-Id: I7808619d0fa3ca63b75796308cfdff6aa41a7fd0 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Android: Improve cache logic in findClass()Christian Strømme2014-10-171-30/+35
| | | | | | | | | | | This change adds guards to ensure that we only do a class look-up once when calling QJNIEnvironmentPrivate::findClass(). IF someone calls findClass() with an environment that does not contain a "valid" class loader, we should fallback to loadClass(), but only once. Change-Id: If5fc82956db889f3269bb33c98a16c49cae55def Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
* Android: Add findClass() function to the QJNIEnvironmentPrivate class.Christian Strømme2014-09-261-48/+90
| | | | | | | | | The static QJNIEnvironmentPrivate::findClass() function exposes the cache and the class finding code in qjni. Change-Id: I42043dc993cf9cace042faf763f2a647ba79d97f Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Android: Avoid caching the same class twice.Christian Strømme2014-08-261-5/+4
| | | | | | | | The class name scheme can be separated by '/' or '.', if both formats where used we would end-up caching those classes twice. Change-Id: I3ae69694d6a8616bbaadfb3c2d0717fbf9ccb9fc Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Fix recursion bug in callStaticMethod()Christian Strømme2014-08-061-3/+3
| | | | | | | | calling callStaticMethod() with template type jlong, jdouble or jboolean would cause the call to loop indefinitely. Change-Id: I99caa576e761fdef623ece04e0779e4cf2535592 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Refactor exception checking in qjni.Christian Strømme2014-07-071-19/+16
| | | | | | | | | In places where we call java/jni functions that can throw exceptions, we check and clear the exception, if necessary. This change moves the "checking" code into a single (private) function. Change-Id: Ic3de2be51305972b096e1ed0a477e341eb5d9404 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Stop ART from complaining about missing thread names.Christian Strømme2014-04-031-1/+10
| | | | | | | | | | The new Android jvm (ART) complains loudly if we attach without supplying a thread name. Task-number: QTBUG-35441 Change-Id: I962d613be0db50f3ca9a4c786b36003f31c9db14 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Check for exception before calling NewGlobalRef().Christian Strømme2014-03-201-2/+14
| | | | | | | | | | Calling NewGlobalRef() throws an exception if it gets an invalid ref. If one of the jni object-calls throws an exception and the returned reference is invalid, the subsequent call to NewGlobalRef() will trigger the second exception and the process will be terminated. Change-Id: I50c622e695542373d5b2eebd911c882e8e0f6bf7 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Fix crash caused by QJNIs classLoader code.Christian Strømme2013-12-041-1/+2
| | | | | | | | | | | | | | In some cases the classLoader is not able to resolve fully-qualified names that contains forward slashes. Unlike FindClass() which expects the fully-qualified name to contain slashes, the classLoader expects the binary name, i.e., with '.' as separator. This caused a crash in QtMultimedia when accessing a nested class. Task-number: QTBUG-35298 Change-Id: I77728352fbab930ae1914bc1cb2189e458e179e2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Android: Fix problem with leaking local refs.Christian Strømme2013-10-301-7/+22
| | | | | | | | | In some cases we where not releasing the local references and since we no longer disconnect from the VM on each call, the number of local refs. would accumulating until it hit the hard-limit of 512. Change-Id: I6826620e4cb61a37af26d276667489e876080076 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* QJNI: Don't detach from the thread as long as the thread is alive.Christian Strømme2013-10-251-16/+13
| | | | | | | | | | | | Attaching and detaching the current thread to/from the VM on each jni call, causes a new thread object to be created and triggers GC when detaching (GC alone takes anything between 10-30 ms to finish on the test device). Instead of detaching when the environment object goes out of scope, we now detach when the thread exits. Task-number: QTBUG-34279 Change-Id: Ia613934e61f914d4be63bfa1be8fdecf849928b0 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Add private ctors in QJNIObjectPrivate that takes va_list.Christian Strømme2013-10-041-0/+37
| | | | | | | | NewObjectV() was failing because QJNIObject was calling the variadic constructors with a va_list, which in turn created a new va_list. Change-Id: I1cf4c8133f237596964177271a20ca651174e695 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Use the application's class loader when loading Java classes.Christian Strømme2013-09-251-4/+12
| | | | | | | | | Previously the system class loader was used, which meant only system Java classes where available. With this change it's no longer necessary to add a JNI_OnLoad() to get a handle to application specific classes. Change-Id: Ic8fe35b4e525bfeb1d317d5ba6b496e39bf9bb30 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Fixed QJNIEnvironment reference counting.Yoann Lopes2013-09-251-3/+5
| | | | | Change-Id: I02369e0c6472375efeffed577d39b764c591e025 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
* Android: Add private API for jni in QtCoreChristian Strømme2013-09-201-0/+2105
When interfacing with Java API's on Android we need to write code using the Java Native Interface (JNI). Writing JNI code requires a lot of boilerplate code to be written. This patch contains API's to minimize the amount of work needed to write JNI code. QJNIEnvironmentPrivate: On creation QJNIEnvironmentPrivate will attach the current running thread to the Java VM, and expose the java environment. QJNIObjectPrivate: Wrapps around a Java class enabling the user to access the class from C++. Change-Id: Ib633437ae36ff513d934292e9eeefcdd5b757d29 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>