]> rtime.felk.cvut.cz Git - orte/eurobot.git/commit
JORTE: prepare for Android (fix class loader problems + add logging)
authorMartin Vajnar <martin.vajnar@gmail.com>
Sun, 7 Jul 2013 16:50:01 +0000 (18:50 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 23 Sep 2013 09:06:25 +0000 (11:06 +0200)
commitb2b73b5c892eb04fc4822340fe9fef3bb99d4e31
tree8db112ea3a6ab83334489c88be6675303b16415d
parentb0dec948790009768c3e9fdc7a904f2056c945a9
JORTE: prepare for Android (fix class loader problems + add logging)

This fixes class loading problems on Android.

As per the Android Documentation (http://developer.android.com/training/articles/perf-jni.html#faq_FindClass):

Android's Dalvik VM uses the loader associated with the method
at the top of the interpreted stack, or if there isn't one
(because the thread was just attached), it uses the "system" class
loader, for FindClass calls.

To overcome this the JNI_OnLoad function is used. Any FindClass calls made
from there will happen in the context of the class loader used to load
the shared library. So from there one class that will always be present
in the JORTE Java package is chosen (org.ocera.orte.JOrte) and it's
class loader is stored as a global reference inside the VM (thus shared
by all processes attached to the VM) and as a static variable (accesible
only by functions from the onLoad.c file) on the C side.Also the findClass
and findLoadedClass method IDs are cached. To simplify the class loading
process inside C functions the findClass functions is written.

Android also doesn't implement the printf function. However it does have
a logging capability, so a variadic macro replacing occurences of printf
with __android_log_print is used.
15 files changed:
orte/include/jorte/4all.h
orte/include/jorte/onLoad.h [new file with mode: 0644]
orte/libjorte/JORTEDomainAppCreate.c
orte/libjorte/JORTEPublicationGetStatus.c
orte/libjorte/JORTEPublicationPropertiesGet.c
orte/libjorte/JORTESubscriptionCreate.c
orte/libjorte/JORTESubscriptionGetStatus.c
orte/libjorte/JORTESubscriptionPropertiesGet.c
orte/libjorte/Makefile.omk
orte/libjorte/createAppInfo.c
orte/libjorte/createPubInfo.c
orte/libjorte/createRecvInfo.c
orte/libjorte/createSubInfo.c
orte/libjorte/onLoad.c [new file with mode: 0644]
orte/libjorte/setRecvInfo.c