summaryrefslogtreecommitdiffstats
path: root/jurt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /jurt
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'jurt')
-rw-r--r--jurt/BUCK21
-rw-r--r--jurt/Jar_jurt.mk16
-rw-r--r--jurt/Library_jpipe.mk94
-rw-r--r--jurt/Library_jpipx.mk20
-rw-r--r--jurt/Makefile7
-rw-r--r--jurt/Module_jurt.mk27
-rw-r--r--jurt/README2
-rw-r--r--jurt/pom.jurt.xml54
-rw-r--r--jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c568
-rw-r--r--jurt/source/pipe/staticsalhack.cxx84
-rw-r--r--jurt/source/pipe/wrapper/wrapper.c118
-rw-r--r--jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java88
-rw-r--r--jurt/workbench/com/sun/star/comp/urlresolver/makefile.mk44
13 files changed, 1143 insertions, 0 deletions
diff --git a/jurt/BUCK b/jurt/BUCK
new file mode 100644
index 000000000..f2349aa01
--- /dev/null
+++ b/jurt/BUCK
@@ -0,0 +1,21 @@
+
+java_sources(
+ name = 'jurt-src',
+ srcs = glob(['com/**']),
+ visibility = ['PUBLIC'],
+)
+
+java_doc(
+ name = 'jurt-javadoc',
+ title = 'LibreOffice Java Uno Runtime',
+ pkgs = [
+ 'com.sun.star',
+ ],
+ paths = ['.'],
+ srcs = glob(['com/**']),
+ deps = [
+ '//:jurt',
+ '//:unoloader',
+ ],
+ visibility = ['PUBLIC'],
+)
diff --git a/jurt/Jar_jurt.mk b/jurt/Jar_jurt.mk
new file mode 100644
index 000000000..faf917fc3
--- /dev/null
+++ b/jurt/Jar_jurt.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Jar_Jar,jurt))
+
+$(eval $(call gb_Jar_add_manifest_classpath,jurt, \
+ libreoffice.jar \
+))
+
+# vim:set noet sw=4 ts=4:
diff --git a/jurt/Library_jpipe.mk b/jurt/Library_jpipe.mk
new file mode 100644
index 000000000..2c1b2f5f3
--- /dev/null
+++ b/jurt/Library_jpipe.mk
@@ -0,0 +1,94 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Library_Library,jpipe))
+
+ifeq ($(OS),WNT)
+
+# The real library is called jpipx on Windows. We build only a wrapper
+# for it here.
+$(eval $(call gb_Library_add_cobjects,jpipe,\
+ jurt/source/pipe/wrapper/wrapper \
+))
+
+else
+
+ifeq ($(COM_IS_CLANG),TRUE)
+ifneq ($(filter -fsanitize=%,$(gb_CC)),)
+Library_jpipe__staticsalhack = TRUE
+endif
+endif
+
+ifeq ($(Library_jpipe__staticsalhack),)
+
+$(eval $(call gb_Library_use_libraries,jpipe,\
+ sal \
+))
+
+$(eval $(call gb_Library_add_cobjects,jpipe,\
+ jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection \
+))
+
+else
+
+# HACK for Clang -fsanitize=address etc. to build libjpipe.so (dlopen'ed from
+# java executable) without dependence on __asan_* etc. symbols (expected to be
+# provided by the executable), incl. statically linking in the relevant parts of
+# sal:
+
+$(eval $(call gb_Library_add_cobjects,jpipe, \
+ jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection \
+))
+
+# see external/dtoa/StaticLibrary_dtoa.mk
+$(eval $(call gb_Library_add_defs,jpipe,\
+ $(if $(filter little,$(ENDIANNESS)),-DIEEE_8087,-DIEEE_MC68k)\
+))
+
+$(eval $(call gb_Library_add_exception_objects,jpipe, \
+ jurt/source/pipe/staticsalhack \
+))
+
+$(eval $(call gb_Library_add_defs,jpipe, \
+ -DRTL_OS="\"$(RTL_OS)"\" \
+ -DRTL_ARCH="\"$(RTL_ARCH)"\" \
+))
+
+$(eval $(call gb_Library_set_include,jpipe, \
+ $$(INCLUDE) \
+ -I$(SRCDIR) \
+ -I$(SRCDIR)/sal/inc \
+ -I$(SRCDIR)/sal/osl/unx \
+ -I$(SRCDIR)/sal/rtl \
+ -I$(SRCDIR)/sal/textenc \
+ -I$(call gb_UnpackedTarball_get_dir,dtoa) \
+ -I$(call gb_UnpackedTarball_get_dir,dtoa/include) \
+))
+
+$(eval $(call gb_Library_use_externals,jpipe, \
+ boost_headers \
+))
+
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_Library_use_system_darwin_frameworks,jpipe, \
+ CoreFoundation \
+))
+endif
+
+$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,jpipe)): \
+ $(call gb_UnpackedTarball_get_target,dtoa)
+$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,jpipe)): \
+ gb_CC := $(filter-out -fsanitize%,$(gb_CC))
+$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,jpipe)): \
+ gb_CXX := $(filter-out -fsanitize%,$(gb_CXX))
+
+endif
+endif
+
+# vim:set noet sw=4 ts=4:
diff --git a/jurt/Library_jpipx.mk b/jurt/Library_jpipx.mk
new file mode 100644
index 000000000..589d9c8ee
--- /dev/null
+++ b/jurt/Library_jpipx.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Library_Library,jpipx))
+
+$(eval $(call gb_Library_use_libraries,jpipx,\
+ sal \
+))
+
+$(eval $(call gb_Library_add_cobjects,jpipx,\
+ jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection \
+))
+
+# vim:set noet sw=4 ts=4:
diff --git a/jurt/Makefile b/jurt/Makefile
new file mode 100644
index 000000000..ccb1c85a0
--- /dev/null
+++ b/jurt/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/jurt/Module_jurt.mk b/jurt/Module_jurt.mk
new file mode 100644
index 000000000..1c0d5baa9
--- /dev/null
+++ b/jurt/Module_jurt.mk
@@ -0,0 +1,27 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Module_Module,jurt))
+
+ifneq ($(ENABLE_JAVA),)
+
+$(eval $(call gb_Module_add_targets,jurt,\
+ Jar_jurt \
+ Library_jpipe \
+))
+
+ifeq ($(OS),WNT)
+$(eval $(call gb_Module_add_targets,jurt,\
+ Library_jpipx \
+))
+endif
+
+endif
+
+# vim:set noet sw=4 ts=4:
diff --git a/jurt/README b/jurt/README
new file mode 100644
index 000000000..a2281d24b
--- /dev/null
+++ b/jurt/README
@@ -0,0 +1,2 @@
+JURT means Java Uno Runtime and implements most of Java UNO.
+
diff --git a/jurt/pom.jurt.xml b/jurt/pom.jurt.xml
new file mode 100644
index 000000000..4db9ff575
--- /dev/null
+++ b/jurt/pom.jurt.xml
@@ -0,0 +1,54 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.libreoffice</groupId>
+ <artifactId>jurt</artifactId>
+ <version>@version@</version>
+ <packaging>jar</packaging>
+ <name>LibreOffice - Java Uno Runtime</name>
+ <description>Java Uno Runtime</description>
+ <url>https://www.libreoffice.org</url>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.libreoffice</groupId>
+ <artifactId>libreoffice</artifactId>
+ <version>@version@</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <licenses>
+ <license>
+ <name>Mozilla Public License, Version 2.0</name>
+ <url>https://www.mozilla.org/en-US/MPL/2.0</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <scm>
+ <url>https://cgit.freedesktop.org/libreoffice/core</url>
+ <connection>https://gerrit.libreoffice.org/#/admin/projects/core</connection>
+ </scm>
+
+ <developers>
+ <developer>
+ <name>The Document Foundation</name>
+ </developer>
+ </developers>
+
+ <mailingLists>
+ <mailingList>
+ <name>LibreOffice Development Mailing List</name>
+ <post>libreoffice@lists.freedesktop.org</post>
+ <subscribe>http://lists.freedesktop.org/mailman/listinfo/libreoffice</subscribe>
+ <unsubscribe>http://lists.freedesktop.org/mailman/listinfo/libreoffice</unsubscribe>
+ <archive>http://lists.freedesktop.org/archives/libreoffice</archive>
+ </mailingList>
+ </mailingLists>
+
+ <issueManagement>
+ <url>https://bugs.documentfoundation.org</url>
+ <system>LibreOffice Issue Tracker</system>
+ </issueManagement>
+</project>
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
new file mode 100644
index 000000000..9b7806b8a
--- /dev/null
+++ b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
@@ -0,0 +1,568 @@
+/* -*- 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 .
+ */
+
+#include <sal/config.h>
+
+#include <stdlib.h>
+
+#include <jni.h>
+#include <osl/security.h>
+#include <osl/pipe.h>
+
+/* On Windows, jpipe.dll must not have static dependencies on any other URE DLLs
+ (sal3.dll, uwinapi.dll), 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 otherwise
+ have to take into account.
+*/
+
+/*****************************************************************************/
+/* exception macros */
+
+static void ThrowException(JNIEnv * env, char const * type, char const * msg) {
+ jclass c;
+ (*env)->ExceptionClear(env);
+ c = (*env)->FindClass(env, type);
+ if (c == NULL) {
+ (*env)->ExceptionClear(env);
+ (*env)->FatalError(env, "JNI FindClass failed");
+ }
+ if ((*env)->ThrowNew(env, c, msg) != 0) {
+ (*env)->ExceptionClear(env);
+ (*env)->FatalError(env, "JNI ThrowNew failed");
+ }
+}
+
+/*****************************************************************************/
+/* helper functions prototypes */
+
+static oslPipe getPipe(JNIEnv * env, jobject obj_this);
+static rtl_uString * jstring2ustring(JNIEnv * env, jstring jstr);
+
+/*****************************************************************************/
+/* get pipe */
+
+static oslPipe getPipe(JNIEnv * env, jobject obj_this)
+{
+ jclass tclass;
+ jfieldID fid;
+ tclass = (*env)->GetObjectClass(env, obj_this);
+ if (tclass == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find class");
+ return NULL;
+ }
+
+ fid = (*env)->GetFieldID(env, tclass, "_nPipeHandle", "J");
+ if (fid == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find field");
+ return NULL;
+ }
+ return (oslPipe) SAL_INT_CAST(
+ sal_IntPtr, (*env)->GetLongField(env, obj_this, fid));
+}
+
+/*****************************************************************************/
+/* convert jstring to rtl_uString */
+
+static rtl_uString * jstring2ustring(JNIEnv * env, jstring jstr)
+{
+ const char * cstr;
+ rtl_uString * ustr = NULL;
+ cstr = (*env)->GetStringUTFChars(env, jstr, NULL);
+ rtl_uString_newFromAscii(&ustr, cstr);
+ (*env)->ReleaseStringUTFChars(env, jstr, cstr);
+ return ustr;
+}
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_lib_connections_pipe_PipeConnection
+ * Method: connect
+ * Signature: (Lcom/sun/star/beans/NativeService;)V
+ */
+SAL_DLLPUBLIC_EXPORT void
+#if defined(_WIN32)
+PipeConnection_create
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI
+#endif
+ (JNIEnv * env, jobject obj_this, jstring name)
+{
+ enum {
+ START = 0,
+ INMONITOR,
+ GOTNAME,
+ CREATED
+ };
+
+ short state = START;
+
+ jclass tclass;
+ jfieldID fid;
+
+ oslSecurity psec = osl_getCurrentSecurity();
+ oslPipe npipe = NULL;
+ rtl_uString * pname = NULL;
+ if ((*env)->MonitorEnter(env, obj_this) != 0)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot synchronize on the object");
+ goto error;
+ }
+ state = INMONITOR;
+
+ /* check connection state */
+ npipe = getPipe(env, obj_this);
+ if ((*env)->ExceptionOccurred(env) != NULL)
+ goto error;
+ if (npipe != NULL)
+ {
+ ThrowException(env,
+ "com/sun/star/io/IOException",
+ "native pipe is already connected");
+ goto error;
+ }
+
+ /* save the pipe name */
+ tclass = (*env)->GetObjectClass(env, obj_this);
+ if (tclass == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find class");
+ goto error;
+ }
+
+ fid = (*env)->GetFieldID(env, tclass,
+ "_aDescription", "Ljava/lang/String;");
+ if (fid == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find field");
+ goto error;
+ }
+
+ (*env)->SetObjectField(env, obj_this, fid, (jobject)name);
+
+ /* convert pipe name to rtl_uString */
+ pname = jstring2ustring(env, name);
+ if (pname == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot convert name");
+ goto error;
+ }
+ state = GOTNAME;
+
+ /* try to connect */
+ npipe = osl_createPipe(pname, osl_Pipe_OPEN, psec);
+ if (npipe == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "cannot create native pipe");
+ goto error;
+ }
+ state = CREATED;
+
+ /* save the pipe */
+ tclass = (*env)->GetObjectClass(env, obj_this);
+ if (tclass == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find class");
+ goto error;
+ }
+
+ fid = (*env)->GetFieldID(env, tclass, "_nPipeHandle", "J");
+ if (fid == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find field");
+ goto error;
+ }
+ (*env)->SetLongField(
+ env, obj_this, fid, SAL_INT_CAST(jlong, (sal_IntPtr) npipe));
+
+ /* done */
+ rtl_uString_release(pname);
+ (*env)->MonitorExit(env, obj_this);
+ osl_freeSecurityHandle(psec);
+ return;
+
+ error:
+ switch (state)
+ {
+ case CREATED:
+ osl_closePipe(npipe);
+ osl_releasePipe(npipe);
+ /* fall through */
+ case GOTNAME:
+ rtl_uString_release(pname);
+ /* fall through */
+ case INMONITOR:
+ (*env)->MonitorExit(env, obj_this);
+ /* fall through */
+ case START:
+ osl_freeSecurityHandle(psec);
+ default:
+ break;
+ }
+ return;
+}
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_lib_connections_pipe_PipeConnection
+ * Method: closeJNI
+ * Signature: ()V
+ */
+SAL_DLLPUBLIC_EXPORT void
+#if defined(_WIN32)
+PipeConnection_close
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI
+#endif
+ (JNIEnv * env, jobject obj_this)
+{
+ enum {
+ START = 0,
+ INMONITOR,
+ GOTPIPE,
+ };
+
+ short state = START;
+ oslPipe npipe = NULL; /* native pipe */
+ jclass tclass; /* this class */
+ jfieldID fid; /* a field identifier */
+
+ if ((*env)->MonitorEnter(env, obj_this) != 0)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot synchronize on the object");
+ goto cleanup;
+ }
+ state = INMONITOR;
+
+ /* check connection state */
+ npipe = getPipe(env, obj_this);
+ if ((*env)->ExceptionOccurred(env) != NULL)
+ goto cleanup;
+ if (npipe == NULL)
+ {
+ ThrowException(env,
+ "com/sun/star/io/IOException",
+ "native pipe is not connected");
+ goto cleanup;
+ }
+ state = GOTPIPE;
+
+ /* remove the reference to the pipe */
+ tclass = (*env)->GetObjectClass(env, obj_this);
+ if (tclass == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find class");
+ goto cleanup;
+ }
+
+ fid = (*env)->GetFieldID(env, tclass, "_nPipeHandle", "J");
+ if (fid == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot find field");
+ goto cleanup;
+ }
+
+ (*env)->SetLongField(env, obj_this, fid, (jlong)0);
+
+ /* done */
+
+ cleanup:
+ switch (state)
+ {
+ case GOTPIPE:
+ /* release the pipe */
+ osl_closePipe(npipe);
+ osl_releasePipe(npipe);
+ /* fall-through */
+ case INMONITOR:
+ (*env)->MonitorExit(env, obj_this);
+ /* fall-through */
+ case START:
+ default:
+ break;
+ }
+ return;
+}
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_lib_connections_pipe_PipeConnection
+ * Method: readJNI
+ * Signature: ([[BI)I
+ */
+SAL_DLLPUBLIC_EXPORT jint
+#if defined(_WIN32)
+PipeConnection_read
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI
+#endif
+ (JNIEnv * env, jobject obj_this, jobjectArray buffer, jint len)
+{
+ enum {
+ START = 0,
+ INMONITOR,
+ ACQUIRED,
+ GOTBUFFER
+ };
+
+ short state = START;
+ oslPipe npipe = NULL; /* native pipe */
+ void * nbuff = NULL; /* native read buffer */
+ jbyteArray bytes; /* java read buffer */
+ jint nread; /* number of bytes has been read */
+ jint nreturn = -1; /* actual return value */
+
+ /* enter monitor */
+ if ((*env)->MonitorEnter(env, obj_this) != 0)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot synchronize on the object");
+ goto cleanup;
+ }
+ state = INMONITOR;
+
+ /* check connection state */
+ npipe = getPipe(env, obj_this);
+ if ((*env)->ExceptionOccurred(env) != NULL)
+ goto cleanup;
+ if (npipe == NULL)
+ {
+ ThrowException(env,
+ "com/sun/star/io/IOException",
+ "native pipe is not connected");
+ goto cleanup;
+ }
+
+ /* acquire pipe */
+ osl_acquirePipe( npipe );
+ state = ACQUIRED;
+
+ /* allocate a buffer */
+ if ((nbuff = malloc(len)) == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe out of memory");
+ goto cleanup;
+ }
+
+ state = GOTBUFFER;
+
+ /* exit monitor */
+ (*env)->MonitorExit(env, obj_this);
+
+ /* reading */
+ nread = osl_readPipe(npipe, nbuff, len);
+
+ /* enter monitor again */
+ if ((*env)->MonitorEnter(env, obj_this) != 0)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot synchronize on the object");
+ goto cleanup;
+ }
+
+ /* copy buffer */
+ if (nread >= 0)
+ {
+ bytes = (*env)->NewByteArray(env, len);
+ if (bytes == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe out of memory");
+ goto cleanup;
+ }
+
+ /* save the data */
+ (*env)->SetByteArrayRegion(env, bytes, 0, len, nbuff);
+ (*env)->SetObjectArrayElement(env, buffer, 0, bytes);
+ (*env)->DeleteLocalRef(env, bytes);
+ }
+
+ /* done */
+ nreturn = nread;
+
+ cleanup:
+ switch (state)
+ {
+ case GOTBUFFER:
+ free(nbuff);
+ /* fall-through */
+ case ACQUIRED:
+ osl_releasePipe(npipe);
+ /* fall-through */
+ case INMONITOR:
+ (*env)->MonitorExit(env, obj_this);
+ /* fall-through */
+ case START:
+ default:
+ break;
+ }
+ return nreturn;
+ }
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_lib_connections_pipe_PipeConnection
+ * Method: writeJNI
+ * Signature: ([B)V
+ */
+SAL_DLLPUBLIC_EXPORT void
+#if defined(_WIN32)
+PipeConnection_write
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI
+#endif
+ (JNIEnv * env, jobject obj_this, jbyteArray buffer)
+{
+ enum {
+ START = 0,
+ INMONITOR,
+ GOTBUFFER
+ };
+
+ short state = START;
+ oslPipe npipe; /* native pipe */
+ sal_Int32 count; /* number of bytes has been written */
+ jsize nwrite; /* number of bytes to write */
+ jbyte * nbuff = NULL; /* native buffer */
+
+ if ((*env)->MonitorEnter(env, obj_this) != 0)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot synchronize on the object");
+ goto cleanup;
+ }
+ state = INMONITOR;
+
+ /* check connection state */
+ npipe = getPipe(env, obj_this);
+ if ((*env)->ExceptionOccurred(env) != NULL)
+ goto cleanup;
+ if (npipe == NULL)
+ {
+ ThrowException(env,
+ "com/sun/star/io/IOException",
+ "native pipe is not connected");
+ goto cleanup;
+ }
+
+ nwrite = (*env)->GetArrayLength(env, buffer);
+ if (nwrite > 0)
+ {
+ nbuff = (*env)->GetByteArrayElements(env, buffer, NULL);
+ if (nbuff == NULL)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe out of memory");
+ goto cleanup;
+ }
+ state = GOTBUFFER;
+
+ (*env)->MonitorExit(env, obj_this);
+ /* writing */
+ count = osl_writePipe(npipe, nbuff, nwrite);
+ if ((*env)->MonitorEnter(env, obj_this) != 0)
+ {
+ ThrowException(env,
+ "java/lang/RuntimeException",
+ "native pipe cannot synchronize on the object");
+ goto cleanup;
+ }
+ if (count != nwrite)
+ {
+ ThrowException(env,
+ "com/sun/star/io/IOException",
+ "native pipe: failed to write");
+ goto cleanup;
+ }
+ }
+ /* done */
+
+ cleanup:
+ switch (state)
+ {
+ case GOTBUFFER:
+ (*env)->ReleaseByteArrayElements(env, buffer, nbuff, JNI_ABORT);
+ /* fall through */
+ case INMONITOR:
+ (*env)->MonitorExit(env, obj_this);
+ /* fall through */
+ case START:
+ default:
+ break;
+ }
+ return;
+}
+
+/*****************************************************************************/
+/*
+ * Class: com_sun_star_lib_connections_pipe_PipeConnection
+ * Method: flushJNI
+ * Signature: ()V
+ */
+SAL_DLLPUBLIC_EXPORT void
+#if defined(_WIN32)
+PipeConnection_flush
+#else
+JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI
+#endif
+ (JNIEnv * env, jobject obj_this)
+{
+ (void) env; /* not used */
+ (void) obj_this; /* not used */
+ return;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/jurt/source/pipe/staticsalhack.cxx b/jurt/source/pipe/staticsalhack.cxx
new file mode 100644
index 000000000..2bcc53e85
--- /dev/null
+++ b/jurt/source/pipe/staticsalhack.cxx
@@ -0,0 +1,84 @@
+/* -*- 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/.
+ */
+
+#define DISABLE_DYNLOADING
+#define NO_CHILD_PROCESSES
+#undef SAL_LOG_INFO
+#undef SAL_LOG_WARN
+
+#include <sal/config.h>
+
+#include <cstdlib>
+
+#include <sal/rtl/string.cxx>
+#include <sal/rtl/ustring.cxx>
+
+#include <sal/osl/unx/conditn.cxx>
+#include <sal/osl/unx/file.cxx>
+#include <sal/osl/unx/file_error_transl.cxx>
+#include <sal/osl/unx/file_misc.cxx>
+#include <sal/osl/unx/file_path_helper.cxx>
+#include <sal/osl/unx/file_stat.cxx>
+#include <sal/osl/unx/file_url.cxx>
+#include <sal/osl/unx/memory.cxx>
+#include <sal/osl/unx/module.cxx>
+#include <sal/osl/unx/mutex.cxx>
+#include <sal/osl/unx/nlsupport.cxx>
+#include <sal/osl/unx/pipe.cxx>
+#include <sal/osl/unx/process.cxx>
+#include <sal/osl/unx/process_impl.cxx>
+#include <sal/osl/unx/profile.cxx>
+#include <sal/osl/unx/readwrite_helper.cxx>
+#include <sal/osl/unx/security.cxx>
+#include <sal/osl/unx/socket.cxx>
+#include <sal/osl/unx/thread.cxx>
+#include <sal/osl/unx/uunxapi.cxx>
+#include <sal/rtl/alloc_arena.cxx>
+#include <sal/rtl/alloc_cache.cxx>
+#include <sal/rtl/alloc_fini.cxx>
+#include <sal/rtl/alloc_global.cxx>
+#include <sal/rtl/bootstrap.cxx>
+#include <sal/rtl/byteseq.cxx>
+#include <sal/rtl/hash.cxx>
+#include <sal/rtl/locale.cxx>
+#include <sal/rtl/math.cxx>
+#include <sal/rtl/strbuf.cxx>
+#include <sal/rtl/strimp.cxx>
+#include <sal/rtl/uri.cxx>
+#include <sal/rtl/ustrbuf.cxx>
+#include <sal/textenc/converter.cxx>
+#include <sal/textenc/convertsimple.cxx>
+#include <sal/textenc/handleundefinedunicodetotextchar.cxx>
+#include <sal/textenc/tcvtutf8.cxx>
+#include <sal/textenc/tencinfo.cxx>
+#include <sal/textenc/textcvt.cxx>
+#include <sal/textenc/textenc.cxx>
+#include <sal/textenc/unichars.cxx>
+
+#if defined MACOSX
+#include <sal/osl/unx/osxlocale.cxx>
+#include <sal/osl/unx/system.cxx>
+#endif
+
+// Called from FullTextEncodingData::get in sal/textenc/textenc.cxx, but only
+// defined for ANDROID (in ANDROID-specific sal/textenc/tables.cxx); would even
+// work to leave it undefined for LINUX due to no '-z defs' under -fsanitize=*
+// (solenv/gbuild/platform/linux.mk), but not for MACOSX:
+extern "C" ImplTextEncodingData const * sal_getFullTextEncodingData(
+ rtl_TextEncoding)
+{
+ std::abort();
+}
+
+#pragma clang diagnostic ignored "-Weverything"
+extern "C" {
+#include <src/dtoa.c> // workdir/UnpackedTarball/dtoa/src/dtoa.c
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/jurt/source/pipe/wrapper/wrapper.c b/jurt/source/pipe/wrapper/wrapper.c
new file mode 100644
index 000000000..83e70dc6f
--- /dev/null
+++ b/jurt/source/pipe/wrapper/wrapper.c
@@ -0,0 +1,118 @@
+/* -*- 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 .
+ */
+
+#include <sal/config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include <jni.h>
+#include <sal/types.h>
+
+
+static HMODULE module = NULL;
+static HINSTANCE hInstDLL = NULL;
+static CRITICAL_SECTION CriticalSection;
+
+static void InitWrapper(void) {
+ #define MAXPATH 512
+ wchar_t path[MAXPATH];
+ DWORD size;
+
+ size = GetModuleFileNameW(hInstDLL, path, MAXPATH);
+ if (size == 0) {
+ abort();
+ }
+ path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
+ module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (module == NULL) {
+ abort();
+ }
+}
+
+static FARPROC getFunction(char const * name)
+{
+ {
+ EnterCriticalSection(&CriticalSection);
+
+ if(module == NULL)
+ InitWrapper();
+
+ LeaveCriticalSection(&CriticalSection);
+ }
+
+ return GetProcAddress(module, name);
+}
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
+ (void) lpvReserved;
+
+ if (fdwReason == DLL_PROCESS_ATTACH)
+ {
+ InitializeCriticalSection(&CriticalSection);
+ hInstDLL = hinstDLL;
+ }
+
+ 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);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java b/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java
new file mode 100644
index 000000000..09ebec87d
--- /dev/null
+++ b/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java
@@ -0,0 +1,88 @@
+/* -*- Mode: Java; 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 .
+ */
+
+package com.sun.star.comp.urlresolver;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.bridge.UnoUrlResolver;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.UnoRuntime;
+
+/** start the office with these options <br>
+ soffice --accept=socket,host=localhost,port=8100;urp;
+*/
+public class UrlResolver_Test
+{
+ public static void main(String[] args) {
+ try {
+ XComponentContext xcomponentcontext = Bootstrap.createInitialComponentContext( null );
+
+ // initial serviceManager
+ xcomponentcontext.getServiceManager();
+
+ // create a connector, so that it can contact the office
+ XUnoUrlResolver urlResolver
+ = UnoUrlResolver.create( xcomponentcontext );
+
+ Object initialObject = urlResolver.resolve(
+ "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" );
+
+ XMultiComponentFactory xOfficeFactory= UnoRuntime.queryInterface(
+ XMultiComponentFactory.class, initialObject );
+
+ // retrieve the component context (it's not yet exported from the office)
+ // Query for the XPropertySet interface.
+ XPropertySet xProperySet = UnoRuntime.queryInterface(
+ XPropertySet.class, xOfficeFactory);
+
+ // Get the default context from the office server.
+ Object oDefaultContext = xProperySet.getPropertyValue( "DefaultContext" );
+
+ // Query for the interface XComponentContext.
+ XComponentContext xOfficeComponentContext = UnoRuntime.queryInterface(
+ XComponentContext.class, oDefaultContext );
+
+ // now create the desktop service
+ // NOTE: use the office component context here !
+ xOfficeFactory.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xOfficeComponentContext );
+ } catch(com.sun.star.connection.NoConnectException e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ } catch(com.sun.star.connection.ConnectionSetupException ce) {
+ System.out.println(ce.getMessage());
+ ce.printStackTrace();
+ } catch(com.sun.star.lang.IllegalArgumentException ie) {
+ System.out.println(ie.getMessage());
+ ie.printStackTrace();
+ } catch(com.sun.star.beans.UnknownPropertyException ue) {
+ System.out.println(ue.getMessage());
+ ue.printStackTrace();
+ } catch(java.lang.Exception ee) {
+ System.out.println(ee.getMessage());
+ ee.printStackTrace();
+ }
+
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/jurt/workbench/com/sun/star/comp/urlresolver/makefile.mk b/jurt/workbench/com/sun/star/comp/urlresolver/makefile.mk
new file mode 100644
index 000000000..8bdbbd8cc
--- /dev/null
+++ b/jurt/workbench/com/sun/star/comp/urlresolver/makefile.mk
@@ -0,0 +1,44 @@
+#
+# 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 .
+#
+
+PRJ := ..$/..$/..$/..$/..$/..
+PRJNAME := jurt
+TARGET := workbench_com_sun_star_comp_urlresolver
+
+PACKAGE := com$/sun$/star$/comp$/urlresolver
+JAVAFILES := UrlResolver_Test.java
+JARFILES := ridl.jar juh.jar
+
+.INCLUDE: settings.mk
+
+# Put the generated class files into <platform>/class/workbench/ instead of
+# <platform>/class/ (otherwise, these class files might end up being zipped into
+# the generated jurt.jar):
+.IF "$(XCLASSPATH)" == ""
+XCLASSPATH := $(CLASSDIR)
+.ELSE
+XCLASSPATH !:= $(XCLASSPATH)$(LIBO_PATH_SEPARATOR)$(CLASSDIR)
+.ENDIF
+CLASSDIR !:= $(CLASSDIR)$/workbench
+
+.INCLUDE: target.mk
+
+$(JAVAFILES): $(MISC)$/$(TARGET).createdclassdir
+$(MISC)$/$(TARGET).createdclassdir:
+ - $(MKDIR) $(CLASSDIR)
+ $(TOUCH) $@