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.