[Libreoffice-commits] .: 6 commits - configure.in distro-configs/LibreOfficeAndroid.conf jvmaccess/source jvmfwk/plugins sal/osl

Tor Lillqvist tml at kemper.freedesktop.org
Thu Nov 24 15:50:25 PST 2011


 configure.in                                        |    6 +++---
 distro-configs/LibreOfficeAndroid.conf              |    1 -
 jvmaccess/source/virtualmachine.cxx                 |   11 ++++++++++-
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx |   17 ++++++++++++++++-
 sal/osl/android/jni/lo-bootstrap.c                  |    5 +++++
 sal/osl/android/jni/lo-bootstrap.h                  |   13 ++++++++++++-
 6 files changed, 46 insertions(+), 7 deletions(-)

New commits:
commit 811de66d7fd8c93c43d8e4e2dc73720033ba939b
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Fri Nov 25 01:40:23 2011 +0200

    First attempt at getting access to the Java VM on Android

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 7b5b262..08193bb 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -35,6 +35,10 @@
 # include <windows.h>
 #endif
 
+#ifdef ANDROID
+# include <dlfcn.h>
+#endif
+
 #if OSL_DEBUG_LEVEL > 0
 #include <stdio.h>
 #endif
@@ -581,6 +585,8 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
     rtl::OUString sRuntimeLib = getRuntimeLib(pInfo->arVendorData);
     JFW_TRACE2(OUSTR("[Java framework] Using Java runtime library: ")
               + sRuntimeLib + OUSTR(".\n"));
+
+#ifndef ANDROID
     // On linux we load jvm with RTLD_GLOBAL. This is necessary for debugging, because
     // libjdwp.so need a symbol (fork1) from libjvm which it only gets if the jvm is loaded
     // witd RTLD_GLOBAL. On Solaris libjdwp.so is correctly linked with libjvm.so
@@ -749,7 +755,16 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
         *ppVm = pJavaVM;
         JFW_TRACE2("[Java framework] sunjavaplugin"SAL_DLLEXTENSION " has created a VM.\n");
     }
-
+#else
+    (void) arOptions;
+    (void) cOptions;
+    // On Android we always have a Java VM as we only expect this code
+    // to be run in an Android app anyway.
+    struct JNIInvokeInterface* * (*lo_get_javavm)(void) = (struct JNIInvokeInterface* * (*)(void)) dlsym(RTLD_DEFAULT, "lo_get_javavm");
+    fprintf(stderr, "Got lo_get_javavm = %p", lo_get_javavm);
+    *ppVm = (JavaVM *) (*lo_get_javavm)();
+    fprintf(stderr, "lo_get_javavm returns %p", (*lo_get_javavm)());
+#endif
 
    return errcode;
 }
commit 15f6fec4d4224857a9dc15ff1e121a93ab4b9541
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Fri Nov 25 01:39:20 2011 +0200

    Add lo_get_javavm() to get the JavaVM we are runnning in

diff --git a/sal/osl/android/jni/lo-bootstrap.c b/sal/osl/android/jni/lo-bootstrap.c
index 2e17155..bd84411 100644
--- a/sal/osl/android/jni/lo-bootstrap.c
+++ b/sal/osl/android/jni/lo-bootstrap.c
@@ -983,6 +983,11 @@ patch(const char *symbol,
          ((((int) replacement_code - ((int) code + 8)) / 4) & 0x00FFFFFF));
 }
 
+JavaVM *
+lo_get_javavm(void)
+{
+    return app->activity->vm;
+}
 
 void
 android_main(struct android_app* state)
diff --git a/sal/osl/android/jni/lo-bootstrap.h b/sal/osl/android/jni/lo-bootstrap.h
index c01ae3c..258d9d2 100644
--- a/sal/osl/android/jni/lo-bootstrap.h
+++ b/sal/osl/android/jni/lo-bootstrap.h
@@ -29,13 +29,17 @@
 
 #if defined(ANDROID)
 
+#include <jni.h>
 #include <dlfcn.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 char **lo_dlneeds(const char *library);
 
 void *lo_dlopen(const char *library);
 
-
 void *lo_dlsym(void *handle,
                const char *symbol);
 
@@ -48,6 +52,13 @@ void *lo_apkentry(const char *filename,
 int lo_dlcall_argc_argv(void *function,
                         int argc,
                         const char **argv);
+
+JavaVM *lo_get_javavm(void);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b1b915c809b86df6cde84ecff091036901f6de14
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Fri Nov 25 01:01:10 2011 +0200

    Android compilation fix

diff --git a/jvmaccess/source/virtualmachine.cxx b/jvmaccess/source/virtualmachine.cxx
index da7aa38..3e12088 100644
--- a/jvmaccess/source/virtualmachine.cxx
+++ b/jvmaccess/source/virtualmachine.cxx
@@ -105,7 +105,16 @@ JNIEnv * VirtualMachine::attachThread(bool * pAttached) const
     }
     if (pEnv == 0)
     {
-        if (m_pVm->AttachCurrentThread(reinterpret_cast< void ** >(&pEnv), 0)
+        if (m_pVm->AttachCurrentThread
+            (
+#ifndef ANDROID
+             reinterpret_cast< void ** >(&pEnv),
+#else
+             // The Android <jni.h> has AttachCurrentThread() taking a
+             // JNIEnv** and not void **
+             &pEnv,
+#endif
+             0)
             != JNI_OK)
             return 0;
         *pAttached = true;
commit 9ee4f4eb52b0c03a2902acc081c847c4514fea35
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Fri Nov 25 00:49:49 2011 +0200

    Android is after all Java-based, so let's not avoid it
    
    An Android app always runs in the context of a Java (well, Dalvik)
    virtual machine.
    
    Sure, there will now be some Java-related compilation errors here and
    there when cross-compiling for Android. Use --without-java if they
    disturb, until I have fixed them.

diff --git a/distro-configs/LibreOfficeAndroid.conf b/distro-configs/LibreOfficeAndroid.conf
index 255ae6a..ce5a8dc 100644
--- a/distro-configs/LibreOfficeAndroid.conf
+++ b/distro-configs/LibreOfficeAndroid.conf
@@ -16,7 +16,6 @@
 --disable-xmlsec
 --enable-python=internal
 --without-fonts
---without-java
 --without-junit
 --without-ppds
 --without-stlport
commit 82a8643ba66b6ef6fe74a417d7a3d7419691bb56
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Fri Nov 25 00:41:00 2011 +0200

    Improve build-time Java checks when cross-compiling from MacOSX

diff --git a/configure.in b/configure.in
index 7cbbc77..6b2d37a 100644
--- a/configure.in
+++ b/configure.in
@@ -4197,7 +4197,7 @@ if test "$SOLAR_JAVA" != ""; then
         fi
         dnl now that we have the path to the real javac, make a JAVA_HOME out of it..
         if test "$JAVA_HOME" != "/usr"; then
-            if test "$_os" = "Darwin"; then
+            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
                 dnl Leopard returns a non-suitable path with readlink - points to "Current" only
                 JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
                 dnl Tiger already returns a JDK path..
@@ -4254,7 +4254,7 @@ _ACEOF
     dnl second sanity check JAVA_HOME if possible
     if test "$JDK" != "gcj" -o "$_gij_longver" -ge "40200"; then
         # now check if $JAVA_HOME is really valid
-        if test "$_os" = "Darwin"; then
+        if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
             if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
                 JAVA_HOME_OK="NO"
             fi
commit 53e9130dd25fdb66fb6122553cc587ddefc51047
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Fri Nov 25 00:38:17 2011 +0200

    Need double-quotes around backticks to avoid test syntax errors

diff --git a/configure.in b/configure.in
index ffdb978..7cbbc77 100644
--- a/configure.in
+++ b/configure.in
@@ -259,7 +259,7 @@ linux-androideabi*)
     # toolchain are set. There aren't really any sensible
     # guesstimates.
     for var in CC CXX AR NM OBJDUMP RANLIB STRIP; do
-        if test -z `eval echo '$'$var`; then
+        if test -z "`eval echo '$'$var`"; then
             AC_MSG_ERROR([You need to set the $var environment variable in a cross-compilation for Android. See README.cross for an example.])
         fi
     done


More information about the Libreoffice-commits mailing list