summaryrefslogtreecommitdiff
path: root/javaunohelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-04-18 13:16:41 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-04-18 15:05:29 +0000
commitff5292c22808c2c4a2abb986fbcbb7999dec565f (patch)
treef5cacce049bc8b0f8153cc36217c2de83166cfd2 /javaunohelper
parent243df043a4ee78509049c5fd5a9f72cce46b029c (diff)
Let juhx.dll export undecorated symbols on Windows
...otherwise preload.cxx in juh.dll will not be able to find them via osl_getFunctionSymbol. What apparently happens is that JNICALL expanding to __stdcall decorates symbol names with _...@NN. This likely was hidden in pre-gbuild times thanks to the use of def files. (On a side note, the JVM appears to contain special code to find syms for native methods in both decorated and undecorated form; that explains why it picks up the decorated symbols from juh.dll just fine.) There is no need for the functions in juhx.dll (called from the juh.dll wrapper) to adhere to JNICALL (in fact, things would likely be easier to maintain if the juhx.dll functions also used different names than their juh.dll wrappers). However, what complicates this patch is that for DISABLE_DYNLOADING, the juh wrapper and its preload.cxx is elided, and the code that would normally go into the juhx library goes into the juh library (and thus needs to stick to JNICALL, and also needs to use the right function names). (cherry picked from commit 96488510c006785bba22c1039885c03e95ac4832) Conflicts: javaunohelper/source/bootstrap.cxx javaunohelper/source/javaunohelper.cxx javaunohelper/source/preload.cxx Change-Id: I66611648f1f79f57f0c1b23fb7a801da2d7b86c5 Reviewed-on: https://gerrit.libreoffice.org/3455 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'javaunohelper')
-rw-r--r--javaunohelper/source/bootstrap.cxx4
-rw-r--r--javaunohelper/source/javaunohelper.cxx10
-rw-r--r--javaunohelper/source/juhx-export-functions.hxx47
-rw-r--r--javaunohelper/source/juhx-export-types.hxx55
-rw-r--r--javaunohelper/source/preload.cxx28
5 files changed, 122 insertions, 22 deletions
diff --git a/javaunohelper/source/bootstrap.cxx b/javaunohelper/source/bootstrap.cxx
index 558a853e6f53..6248d09ef13f 100644
--- a/javaunohelper/source/bootstrap.cxx
+++ b/javaunohelper/source/bootstrap.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "sal/config.h"
#include "osl/diagnose.h"
@@ -36,6 +37,7 @@
#include "jvmaccess/virtualmachine.hxx"
#include "jvmaccess/unovirtualmachine.hxx"
+#include "juhx-export-functions.hxx"
#include "vm.hxx"
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
@@ -66,7 +68,7 @@ inline ::rtl::OUString jstring_to_oustring( jstring jstr, JNIEnv * jni_env )
}
//==================================================================================================
-extern "C" SAL_JNI_EXPORT jobject JNICALL Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap(
+jobject Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap(
JNIEnv * jni_env, SAL_UNUSED_PARAMETER jclass, jstring juno_rc, jobjectArray jpairs,
jobject loader )
{
diff --git a/javaunohelper/source/javaunohelper.cxx b/javaunohelper/source/javaunohelper.cxx
index 45c93926cbe3..5536ced7f49d 100644
--- a/javaunohelper/source/javaunohelper.cxx
+++ b/javaunohelper/source/javaunohelper.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "sal/config.h"
#include <osl/diagnose.h>
#include <osl/module.h>
@@ -37,6 +38,7 @@
#include "jvmaccess/virtualmachine.hxx"
#include "jvmaccess/unovirtualmachine.hxx"
+#include "juhx-export-functions.hxx"
#include "vm.hxx"
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
@@ -52,8 +54,7 @@ using ::rtl::OUString;
* Method: component_writeInfo
* Signature: (Ljava/lang/String;Lcom/sun/star/lang/XMultiServiceFactory;Lcom/sun/star/registry/XRegistryKey;)Z
*/
-extern "C" SAL_JNI_EXPORT jboolean JNICALL
-Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
+jboolean Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
JNIEnv * pJEnv, SAL_UNUSED_PARAMETER jclass, jstring jLibName, jobject jSMgr,
jobject jRegKey, jobject loader )
{
@@ -139,8 +140,7 @@ Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
* Method: component_getFactory
* Signature: (Ljava/lang/String;Ljava/lang/String;Lcom/sun/star/lang/XMultiServiceFactory;Lcom/sun/star/registry/XRegistryKey;)Ljava/lang/Object;
*/
-extern "C" SAL_JNI_EXPORT jobject JNICALL
-Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
+jobject Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
JNIEnv * pJEnv, SAL_UNUSED_PARAMETER jclass, jstring jLibName, jstring jImplName,
jobject jSMgr, jobject jRegKey, jobject loader )
{
@@ -246,7 +246,7 @@ Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
* Method: createRegistryServiceFactory
* Signature: (Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/Object;
*/
-extern "C" SAL_JNI_EXPORT jobject JNICALL
+jobject
Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory(
JNIEnv * pJEnv, SAL_UNUSED_PARAMETER jclass, jstring jWriteRegFile,
jstring jReadRegFile, jboolean jbReadOnly, jobject loader )
diff --git a/javaunohelper/source/juhx-export-functions.hxx b/javaunohelper/source/juhx-export-functions.hxx
new file mode 100644
index 000000000000..0ecd75c8fcdc
--- /dev/null
+++ b/javaunohelper/source/juhx-export-functions.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_JAVAUNOHELPER_SOURCE_JUHX_EXPORT_FUNCTIONS_HXX
+#define INCLUDED_JAVAUNOHELPER_SOURCE_JUHX_EXPORT_FUNCTIONS_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#include "juhx-export-types.hxx"
+
+extern "C" {
+
+SAL_JNI_EXPORT javaunohelper::detail::Func_bootstrap
+Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap;
+
+SAL_JNI_EXPORT javaunohelper::detail::Func_createRegistryServiceFactory
+Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory;
+
+SAL_JNI_EXPORT javaunohelper::detail::Func_getFactory
+Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory;
+
+SAL_JNI_EXPORT javaunohelper::detail::Func_writeInfo
+Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo;
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/source/juhx-export-types.hxx b/javaunohelper/source/juhx-export-types.hxx
new file mode 100644
index 000000000000..ff9bf62d09d2
--- /dev/null
+++ b/javaunohelper/source/juhx-export-types.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_JAVAUNOHELPER_SOURCE_JUHX_EXPORT_TYPES_HXX
+#define INCLUDED_JAVAUNOHELPER_SOURCE_JUHX_EXPORT_TYPES_HXX
+
+#include "sal/config.h"
+
+#include "jni.h"
+
+#if defined DISABLE_DYNLOADING
+#define JAVAUNOHELPER_DETAIL_CALLCONV JNICALL
+#else
+#define JAVAUNOHELPER_DETAIL_CALLCONV
+#endif
+
+extern "C" {
+
+namespace javaunohelper { namespace detail {
+
+typedef jobject JAVAUNOHELPER_DETAIL_CALLCONV Func_bootstrap(
+ JNIEnv *_env, jclass, jstring, jobjectArray, jobject);
+
+typedef jobject JAVAUNOHELPER_DETAIL_CALLCONV Func_createRegistryServiceFactory(
+ JNIEnv *, jclass, jstring, jstring, jboolean, jobject );
+
+typedef jobject JAVAUNOHELPER_DETAIL_CALLCONV Func_getFactory(
+ JNIEnv *, jclass, jstring, jstring, jobject, jobject, jobject);
+
+typedef jboolean JAVAUNOHELPER_DETAIL_CALLCONV Func_writeInfo(
+ JNIEnv *, jclass, jstring, jobject, jobject, jobject);
+
+} }
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/javaunohelper/source/preload.cxx b/javaunohelper/source/preload.cxx
index c188d82a4ea7..afe2ec0d2fbe 100644
--- a/javaunohelper/source/preload.cxx
+++ b/javaunohelper/source/preload.cxx
@@ -17,12 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "sal/config.h"
#include "jni.h"
#include "rtl/ustring.hxx"
#include "osl/module.h"
+#include "juhx-export-types.hxx"
+
// In retrospect, the reason to create a juh wrapper around the juhx library was
// probably because java.lang.System.loadLibrary uses RTLD_LOCAL, so uniqueness
// of GCC RTTI symbols needed for exception handling would not be guaranteed.
@@ -37,19 +40,12 @@ using ::rtl::OUString;
extern "C"
{
-typedef jboolean (JNICALL * fptr_writeInfo)(
- JNIEnv *, jclass, jstring, jobject, jobject, jobject );
-typedef jobject (JNICALL * fptr_getFactory)(
- JNIEnv *, jclass, jstring, jstring, jobject, jobject, jobject );
-typedef jobject (JNICALL * fptr_createRegistryServiceFactory)(
- JNIEnv *, jclass, jstring, jstring, jboolean, jobject );
-typedef jobject (JNICALL * fptr_bootstrap)(
- JNIEnv *_env, jclass, jstring, jobjectArray, jobject );
-static fptr_writeInfo s_writeInfo;
-static fptr_getFactory s_getFactory;
-static fptr_createRegistryServiceFactory s_createRegistryServiceFactory;
-static fptr_bootstrap s_bootstrap;
+static javaunohelper::detail::Func_writeInfo * s_writeInfo;
+static javaunohelper::detail::Func_getFactory * s_getFactory;
+static javaunohelper::detail::Func_createRegistryServiceFactory *
+ s_createRegistryServiceFactory;
+static javaunohelper::detail::Func_bootstrap * s_bootstrap;
static bool s_inited = false;
extern "C" { static void SAL_CALL thisModule() {} }
@@ -73,21 +69,21 @@ static bool inited_juhx( JNIEnv * jni_env )
{
OUString symbol =
OUSTR("Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo");
- s_writeInfo = (fptr_writeInfo)osl_getFunctionSymbol(
+ s_writeInfo = (javaunohelper::detail::Func_writeInfo *)osl_getFunctionSymbol(
hModule, symbol.pData );
symbol =
OUSTR("Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory");
- s_getFactory = (fptr_getFactory)osl_getFunctionSymbol(
+ s_getFactory = (javaunohelper::detail::Func_getFactory *)osl_getFunctionSymbol(
hModule, symbol.pData );
symbol =
OUSTR("Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory");
s_createRegistryServiceFactory =
- (fptr_createRegistryServiceFactory)osl_getFunctionSymbol(
+ (javaunohelper::detail::Func_createRegistryServiceFactory *)osl_getFunctionSymbol(
hModule, symbol.pData );
symbol =
OUSTR("Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap");
s_bootstrap =
- (fptr_bootstrap)osl_getFunctionSymbol( hModule, symbol.pData );
+ (javaunohelper::detail::Func_bootstrap *)osl_getFunctionSymbol( hModule, symbol.pData );
if (0 == s_writeInfo ||
0 == s_getFactory ||