summaryrefslogtreecommitdiff
path: root/jurt
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2010-04-16 16:24:56 +0200
committersb <sb@openoffice.org>2010-04-16 16:24:56 +0200
commit462d351e9d4038ebad0fa11c8c77106a3b7bd3c9 (patch)
treeb143066a3f6b261c544712c0a3dbb710e058a99a /jurt
parent640a983fa652a2d1558cd506fca2c92d6093967a (diff)
sb120: #i110944# jpipe.dll wrapper around jpipx.dll
Diffstat (limited to 'jurt')
-rw-r--r--jurt/com/sun/star/lib/connections/pipe/PipeConnection.java24
-rw-r--r--jurt/prj/build.lst1
-rw-r--r--jurt/prj/d.lst3
-rw-r--r--jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c47
-rw-r--r--jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h53
-rw-r--r--jurt/source/pipe/jpipe.dxp5
-rw-r--r--jurt/source/pipe/makefile.mk96
-rw-r--r--jurt/source/pipe/wrapper/makefile.mk52
-rw-r--r--jurt/source/pipe/wrapper/wrapper.c99
9 files changed, 253 insertions, 127 deletions
diff --git a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java
index 997b9d1c76ee..455e3aab6502 100644
--- a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java
+++ b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java
@@ -58,30 +58,8 @@ public class PipeConnection implements XConnection, XConnectionBroadcaster {
static public final boolean DEBUG = false;
static {
- // preload shared libraries whichs import lips are linked to jpipe
- if ( System.getProperty( "os.name" ).startsWith( "Windows" ) )
- {
- try {
- NativeLibraryLoader.loadLibrary(PipeConnection.class.getClassLoader(), "msvcr71");
- } catch (Throwable e){} // loading twice would fail
-
- try {
- NativeLibraryLoader.loadLibrary(PipeConnection.class.getClassLoader(), "msvcr70");
- } catch (Throwable e){} // loading twice would fail
-
- try {
- NativeLibraryLoader.loadLibrary(PipeConnection.class.getClassLoader(), "uwinapi");
- } catch (Throwable e){} // loading twice would fail
-
- try {
- NativeLibraryLoader.loadLibrary(PipeConnection.class.getClassLoader(), "sal3");
- } catch (Throwable e){} // loading twice would fail
- }
-
// load shared library for JNI code
- try {
- NativeLibraryLoader.loadLibrary(PipeConnection.class.getClassLoader(), "jpipe");
- } catch (Throwable e){} // loading twice would fail
+ NativeLibraryLoader.loadLibrary(PipeConnection.class.getClassLoader(), "jpipe");
}
protected String _aDescription;
diff --git a/jurt/prj/build.lst b/jurt/prj/build.lst
index f3d498b8cdd6..9b9b722bc3ae 100644
--- a/jurt/prj/build.lst
+++ b/jurt/prj/build.lst
@@ -15,4 +15,5 @@ ju jurt\com\sun\star\comp\connections nmake - all ju_con ju_co_loader NULL
ju jurt\com\sun\star\comp\servicemanager nmake - all ju_servman NULL
ju jurt\com\sun\star\comp\urlresolver nmake - all ju_urlres ju_co_loader NULL
ju jurt\source\pipe nmake - all ju_src_pipe NULL
+ju jurt\source\pipe\wrapper nmake - w ju_src_pipe_wrapper NULL
ju jurt\util nmake - all ju_ut ju_brid_jrm ju_co_bfactr ju_con ju_con_sock ju_con_pipe ju_cssl_uno ju_env_java ju_prot_urp ju_servman ju_urlres ju_src_pipe ju_libutil ju_uno NULL
diff --git a/jurt/prj/d.lst b/jurt/prj/d.lst
index 5223fe2fe5ee..848435f61138 100644
--- a/jurt/prj/d.lst
+++ b/jurt/prj/d.lst
@@ -1,5 +1,6 @@
..\%__SRC%\class\jurt.jar %_DEST%\bin%_EXT%\jurt.jar
-..\%__SRC%\bin\jpipe*.dll %_DEST%\bin%_EXT%\jpipe*.dll
+..\%__SRC%\bin\jpipe.dll %_DEST%\bin%_EXT%\jpipe.dll
+..\%__SRC%\bin\jpipx.dll %_DEST%\bin%_EXT%\jpipx.dll
..\%__SRC%\lib\libjpipe*.so %_DEST%\lib%_EXT%\libjpipe*.so
..\%__SRC%\lib\libjpipe*.dylib %_DEST%\lib%_EXT%\libjpipe*.dylib
diff --git a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
index 255da24c2f86..4d0a5b357604 100644
--- a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
+++ b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
@@ -25,10 +25,20 @@
*
************************************************************************/
+#include "jni.h"
#include "osl/security.h"
#include <osl/pipe.h>
-#include "com_sun_star_lib_connections_pipe_PipeConnection.h"
+/* On Windows, jpipe.dll must not have dependencies on any other URE DLLs, as
+ Java System.LoadLibrary could otherwise not load it. Therefore, on Windows,
+ this code goes into a jpipx.dll that the jpipe.dll wrapper loads with
+ LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH). The function names in this
+ wrapped code are truncated from the long JNICALL names, as JNICALL causes
+ some "@N" with different numeric values for N (and probably different across
+ 32 and 64 bit) to be added to the symbol names, which the calls to
+ GetProcAddress in wrapper/wrapper.c would otheriwse have to take into
+ account.
+*/
/*****************************************************************************/
/* exception macros */
@@ -100,7 +110,12 @@ static rtl_uString * jstring2ustring(JNIEnv * env, jstring jstr)
* Method: connect
* Signature: (Lcom/sun/star/beans/NativeService;)V
*/
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI
+SAL_DLLPUBLIC_EXPORT void
+#if defined WNT
+PipeConnection_create
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI
+#endif
(JNIEnv * env, jobject obj_this, jstring name)
{
enum {
@@ -234,7 +249,12 @@ JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_cre
* Method: closeJNI
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI
+SAL_DLLPUBLIC_EXPORT void
+#if defined WNT
+PipeConnection_close
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI
+#endif
(JNIEnv * env, jobject obj_this)
{
enum {
@@ -315,7 +335,12 @@ JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_clo
* Method: readJNI
* Signature: ([[BI)I
*/
-JNIEXPORT jint JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI
+SAL_DLLPUBLIC_EXPORT jint
+#if defined WNT
+PipeConnection_read
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI
+#endif
(JNIEnv * env, jobject obj_this, jobjectArray buffer, jint len)
{
enum {
@@ -430,7 +455,12 @@ JNIEXPORT jint JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_rea
* Method: writeJNI
* Signature: ([B)V
*/
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI
+SAL_DLLPUBLIC_EXPORT void
+#if defined WNT
+PipeConnection_write
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI
+#endif
(JNIEnv * env, jobject obj_this, jbyteArray buffer)
{
enum {
@@ -522,7 +552,12 @@ JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_wri
* Method: flushJNI
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI
+SAL_DLLPUBLIC_EXPORT void
+#if defined WNT
+PipeConnection_flush
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI
+#endif
(JNIEnv * env, jobject obj_this)
{
(void) env; /* not used */
diff --git a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h
deleted file mode 100644
index a21e8f979348..000000000000
--- a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class com_sun_star_connections_pipe_PipeConnection */
-
-#ifndef _Included_com_sun_star_lib_connections_pipe_PipeConnection_h
-#define _Included_com_sun_star_lib_connections_pipe_PipeConnection_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: com_sun_star_lib_connections_pipe_PipeConnection
- * Method: connect
- * Signature: (Ljava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI
- (JNIEnv *, jobject, jstring);
-
-/*
- * Class: com_sun_star_lib_connections_pipe_PipeConnection
- * Method: readJNI
- * Signature: ([[BI)I
- */
-JNIEXPORT jint JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI
- (JNIEnv *, jobject, jobjectArray, jint);
-
-/*
- * Class: com_sun_star_lib_connections_pipe_PipeConnection
- * Method: writeJNI
- * Signature: ([B)V
- */
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI
- (JNIEnv *, jobject, jbyteArray);
-
-/*
- * Class: com_sun_star_lib_connections_pipe_PipeConnection
- * Method: flushJNI
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sun_star_lib_connections_pipe_PipeConnection
- * Method: closeJNI
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI
- (JNIEnv *, jobject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/jurt/source/pipe/jpipe.dxp b/jurt/source/pipe/jpipe.dxp
deleted file mode 100644
index e07ea907470f..000000000000
--- a/jurt/source/pipe/jpipe.dxp
+++ /dev/null
@@ -1,5 +0,0 @@
-Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI
-Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI
-Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI
-Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI
-Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI
diff --git a/jurt/source/pipe/makefile.mk b/jurt/source/pipe/makefile.mk
index e56ece77f5c1..5be6f1ebfd10 100644
--- a/jurt/source/pipe/makefile.mk
+++ b/jurt/source/pipe/makefile.mk
@@ -1,39 +1,57 @@
-PRJ=..$/..
-
-PRJNAME=jurt
-TARGET=jpipe
-ENABLE_EXCEPTIONS=TRUE
-
-#?
-NO_DEFAULT_STL=TRUE
-NO_BSYMBOLIC=TRUE
-USE_DEFFILE=TRUE
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-.IF "$(SOLAR_JAVA)"==""
-nojava:
- @echo "Not building jurt because Java is disabled"
-.ENDIF
-
-# --- Files --------------------------------------------------------
-
-SLOFILES = \
- $(SLO)$/com_sun_star_lib_connections_pipe_PipeConnection.obj
-
-SHL1TARGET=$(TARGET)
-SHL1LIBS=$(SLB)$/$(TARGET).lib
-SHL1STDLIBS=$(SALLIB)
-SHL1DEF=$(MISC)$/$(SHL1TARGET).def
-SHL1RPATH=URELIB
-
-DEF1NAME=$(SHL1TARGET)
-DEF1EXPORTFILE=$(TARGET).dxp
-DEF1DES=jurtpipe
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#***********************************************************************/
+
+PRJ = ../..
+PRJNAME = jurt
+TARGET = jpipe
+
+NO_DEFAULT_STL = TRUE
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+
+.IF "$(OS)" == "WNT"
+SHL1TARGET = jpipx
+.ELSE
+SHL1TARGET = jpipe
+.END
+
+SHL1CODETYPE = C
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1OBJS = $(SLO)/com_sun_star_lib_connections_pipe_PipeConnection.obj
+SHL1RPATH = URELIB
+SHL1STDLIBS = $(SALLIB)
+SHL1USE_EXPORTS = name
+DEF1NAME = $(SHL1TARGET)
+
+SLOFILES = $(SHL1OBJS)
+
+.IF "$(SOLAR_JAVA)" == ""
+nothing .PHONY :
+.END
+
+.INCLUDE: target.mk
diff --git a/jurt/source/pipe/wrapper/makefile.mk b/jurt/source/pipe/wrapper/makefile.mk
new file mode 100644
index 000000000000..88a3b160da2e
--- /dev/null
+++ b/jurt/source/pipe/wrapper/makefile.mk
@@ -0,0 +1,52 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#***********************************************************************/
+
+PRJ = ../../..
+PRJNAME = jurt
+TARGET = wrapper
+
+NO_DEFAULT_STL = TRUE
+UWINAPILIB =
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+
+SHL1CODETYPE = C
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1OBJS = $(SLO)/wrapper.obj
+SHL1RPATH = URELIB
+SHL1TARGET = jpipe
+SHL1USE_EXPORTS = name
+DEF1NAME = $(SHL1TARGET)
+
+SLOFILES = $(SHL1OBJS)
+
+.IF "$(SOLAR_JAVA)" == ""
+nothing .PHONY :
+.END
+
+.INCLUDE: target.mk
diff --git a/jurt/source/pipe/wrapper/wrapper.c b/jurt/source/pipe/wrapper/wrapper.c
new file mode 100644
index 000000000000..5ef40f009191
--- /dev/null
+++ b/jurt/source/pipe/wrapper/wrapper.c
@@ -0,0 +1,99 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "sal/config.h"
+
+#include <stddef.h>
+
+#include <Windows.h>
+
+#include "jni.h"
+#include "sal/types.h"
+
+static HMODULE module;
+
+static FARPROC getFunction(char const * name) {
+ return GetProcAddress(module, name);
+}
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
+ (void) lpvReserved;
+ if (fdwReason == DLL_PROCESS_ATTACH) {
+ wchar_t path[32767];
+ DWORD size;
+ size = GetModuleFileNameW(hinstDLL, path, 32767);
+ if (size == 0) {
+ return FALSE;
+ }
+ path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
+ module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (module == NULL) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+SAL_DLLPUBLIC_EXPORT void JNICALL
+Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI(
+ JNIEnv * env, jobject obj_this, jstring name)
+{
+ (*(void (*)(JNIEnv *, jobject, jstring))
+ getFunction("PipeConnection_create"))(env, obj_this, name);
+}
+
+SAL_DLLPUBLIC_EXPORT void JNICALL
+Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI(
+ JNIEnv * env, jobject obj_this)
+{
+ (*(void (*)(JNIEnv *, jobject))
+ getFunction("PipeConnection_close"))(env, obj_this);
+}
+
+SAL_DLLPUBLIC_EXPORT jint JNICALL
+Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI(
+ JNIEnv * env, jobject obj_this, jobjectArray buffer, jint len)
+{
+ return (*(jint (*)(JNIEnv *, jobject, jobjectArray, jint))
+ getFunction("PipeConnection_read"))(env, obj_this, buffer, len);
+}
+
+SAL_DLLPUBLIC_EXPORT void JNICALL
+Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI(
+ JNIEnv * env, jobject obj_this, jbyteArray buffer)
+{
+ (*(void (*)(JNIEnv *, jobject, jbyteArray))
+ getFunction("PipeConnection_write"))(env, obj_this, buffer);
+}
+
+SAL_DLLPUBLIC_EXPORT void JNICALL
+Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI(
+ JNIEnv * env, jobject obj_this)
+{
+ (*(void (*)(JNIEnv *, jobject))
+ getFunction("PipeConnection_flush"))(env, obj_this);
+}