aboutsummaryrefslogtreecommitdiffstats
path: root/java_jni/jni/jau
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-01-25 01:28:36 +0100
committerSven Gothel <[email protected]>2021-01-25 01:28:36 +0100
commitb371af6d83e0fb94cba02ec6c2837bf58c2eea39 (patch)
tree48999c7e269409ebe389e5d5e72ca141d8b9eea7 /java_jni/jni/jau
parent1ba932716f2d382af56bf8ea69a57666e2c835d6 (diff)
Java import and modularization: jaulib_base, jaulib_jni, jaulib_net, jaulib_pkg (WIP)
Diffstat (limited to 'java_jni/jni/jau')
-rw-r--r--java_jni/jni/jau/Clock.cxx65
-rw-r--r--java_jni/jni/jau/JVM_JNI8.cxx46
-rw-r--r--java_jni/jni/jau/MachineDataInfoRuntime.cxx211
-rw-r--r--java_jni/jni/jau/UnixDynamicLinkerImpl_JNI.cxx138
-rw-r--r--java_jni/jni/jau/WindowsDynamicLinkerImpl_JNI.cxx107
5 files changed, 567 insertions, 0 deletions
diff --git a/java_jni/jni/jau/Clock.cxx b/java_jni/jni/jau/Clock.cxx
new file mode 100644
index 0000000..06afa03
--- /dev/null
+++ b/java_jni/jni/jau/Clock.cxx
@@ -0,0 +1,65 @@
+/*
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "org_jau_sys_Clock.h"
+
+#include <cstdint>
+#include <cinttypes>
+
+#include <time.h>
+
+#include <jau/environment.hpp>
+
+#include "jau/jni/helper_jni.hpp"
+
+
+static const int64_t NanoPerMilli = 1000000L;
+static const int64_t MilliPerOne = 1000L;
+
+/**
+ * See <http://man7.org/linux/man-pages/man2/clock_gettime.2.html>
+ * <p>
+ * Regarding avoiding kernel via VDSO,
+ * see <http://man7.org/linux/man-pages/man7/vdso.7.html>,
+ * clock_gettime seems to be well supported at least on kernel >= 4.4.
+ * Only bfin and sh are missing, while ia64 seems to be complicated.
+ */
+jlong Java_org_jau_sys_Clock_currentTimeMillis(JNIEnv *env, jclass clazz) {
+ (void)env;
+ (void)clazz;
+
+ struct timespec t;
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ int64_t res = t.tv_sec * MilliPerOne + t.tv_nsec / NanoPerMilli;
+ return (jlong)res;
+}
+
+jlong Java_org_jau_sys_Clock_startupTimeMillisImpl(JNIEnv *env, jclass clazz) {
+ (void)env;
+ (void)clazz;
+
+ return jau::environment::startupTimeMilliseconds;
+}
+
diff --git a/java_jni/jni/jau/JVM_JNI8.cxx b/java_jni/jni/jau/JVM_JNI8.cxx
new file mode 100644
index 0000000..f6487e8
--- /dev/null
+++ b/java_jni/jni/jau/JVM_JNI8.cxx
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2019 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+#include <stdio.h> //required by android to identify NULL
+#include <jni.h>
+
+#if defined (JNI_VERSION_1_8)
+
+JNIEXPORT jint JNICALL JNI_OnLoad_jaulib_jni_jni(JavaVM *vm, void *reserved) {
+ (void)vm;
+ (void)reserved;
+ return JNI_VERSION_1_8;
+}
+
+JNIEXPORT void JNICALL JNI_OnUnload_jaulib_jni_jni(JavaVM *vm, void *reserved) {
+ (void)vm;
+ (void)reserved;
+}
+
+#endif /* defined (JNI_VERSION_1_8) */
+
diff --git a/java_jni/jni/jau/MachineDataInfoRuntime.cxx b/java_jni/jni/jau/MachineDataInfoRuntime.cxx
new file mode 100644
index 0000000..98ee97a
--- /dev/null
+++ b/java_jni/jni/jau/MachineDataInfoRuntime.cxx
@@ -0,0 +1,211 @@
+
+#include <jni.h>
+
+#include <assert.h>
+
+#include "jau_sys_MachineDataInfoRuntime.h"
+
+#include "jau/jni/helper_jni.hpp"
+
+#if defined(_WIN32)
+ #include <windows.h>
+#else /* assume POSIX sysconf() availability */
+ #include <unistd.h>
+#endif
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getPointerSizeInBytesImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return sizeof(void *);
+}
+
+JNIEXPORT jlong JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getPageSizeInBytesImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+#if defined(_WIN32)
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ return (jlong) si.dwPageSize;
+#else
+ return (jlong) sysconf(_SC_PAGESIZE);
+#endif
+}
+
+typedef struct {
+ int8_t c1;
+ int8_t v;
+} struct_alignment_int8;
+
+typedef struct {
+ int8_t c1;
+ int16_t v;
+} struct_alignment_int16;
+
+typedef struct {
+ int8_t c1;
+ int32_t v;
+} struct_alignment_int32;
+
+typedef struct {
+ int8_t c1;
+ int64_t v;
+} struct_alignment_int64;
+
+typedef struct {
+ int8_t c1;
+ int v;
+} struct_alignment_int;
+
+typedef struct {
+ int8_t c1;
+ long v;
+} struct_alignment_long;
+
+typedef struct {
+ int8_t c1;
+ void * v;
+} struct_alignment_pointer;
+
+typedef struct {
+ int8_t c1;
+ float v;
+} struct_alignment_float;
+
+typedef struct {
+ int8_t c1;
+ double v;
+} struct_alignment_double;
+
+typedef struct {
+ int8_t c1;
+ long double v;
+} struct_alignment_ldouble;
+
+// size_t padding(size_t totalsize, size_t typesize) { return totalsize - typesize - sizeof(char); }
+// static size_t alignment(size_t totalsize, size_t typesize) { return totalsize - typesize; }
+#define ALIGNMENT(a, b) ( (a) - (b) )
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentInt8Impl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_int8 ), sizeof(int8_t));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentInt16Impl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_int16 ), sizeof(int16_t));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentInt32Impl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_int32 ), sizeof(int32_t));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentInt64Impl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_int64 ), sizeof(int64_t));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentIntImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_int ), sizeof(int));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentLongImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_long ), sizeof(long));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentPointerImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_pointer ), sizeof(void *));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentFloatImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_float ), sizeof(float));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentDoubleImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_double ), sizeof(double));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getAlignmentLongDoubleImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return ALIGNMENT(sizeof( struct_alignment_ldouble ), sizeof(long double));
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getSizeOfIntImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return sizeof(int);
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getSizeOfLongImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return sizeof(long);
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getSizeOfFloatImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return sizeof(float);
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getSizeOfDoubleImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return sizeof(double);
+}
+
+JNIEXPORT jint JNICALL
+Java_jau_sys_MachineDataInfoRuntime_getSizeOfLongDoubleImpl(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ return sizeof(long double);
+}
+
diff --git a/java_jni/jni/jau/UnixDynamicLinkerImpl_JNI.cxx b/java_jni/jni/jau/UnixDynamicLinkerImpl_JNI.cxx
new file mode 100644
index 0000000..9a7a57c
--- /dev/null
+++ b/java_jni/jni/jau/UnixDynamicLinkerImpl_JNI.cxx
@@ -0,0 +1,138 @@
+/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:26:59 PDT 2006 ----! */
+
+#include <jni.h>
+
+#include <assert.h>
+
+#include "jau_sys_dl_UnixDynamicLinkerImpl.h"
+
+ #include <dlfcn.h>
+ #include <inttypes.h>
+
+#ifndef RTLD_DEFAULT
+ #define RTLD_DEFAULT ((void *) 0)
+#endif
+
+// #define DEBUG_DLOPEN 1
+
+#ifdef DEBUG_DLOPEN
+ typedef void *(*DLOPEN_FPTR_TYPE)(const char *filename, int flag);
+ #define VERBOSE_ON 1
+#endif
+
+// #define VERBOSE_ON 1
+
+#ifdef VERBOSE_ON
+ #ifdef ANDROID
+ #include <android/log.h>
+ #define DBG_PRINT(...) __android_log_print(ANDROID_LOG_DEBUG, "JogAmp", __VA_ARGS__)
+ #else
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+ #endif
+#else
+ #define DBG_PRINT(...)
+#endif
+
+/*
+ * Class: jau_sys_dl_UnixDynamicLinkerImpl
+ * Method: dlclose
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL
+Java_jau_sys_dl_UnixDynamicLinkerImpl_dlclose(JNIEnv *env, jclass _unused, jlong arg0) {
+ (void)env;
+ (void)_unused;
+
+ int _res;
+ _res = dlclose((void *) (intptr_t) arg0);
+ return _res;
+}
+
+
+/*
+ * Class: jau_sys_dl_UnixDynamicLinkerImpl
+ * Method: dlerror
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_jau_sys_dl_UnixDynamicLinkerImpl_dlerror(JNIEnv *env, jclass _unused) {
+ (void)_unused;
+
+ char * _res;
+ _res = dlerror();
+ if (_res == NULL) return NULL; return env->NewStringUTF(_res);
+}
+
+/*
+ * Class: jau_sys_dl_UnixDynamicLinkerImpl
+ * Method: dlopen
+ * Signature: (Ljava/lang/String;I)J
+ */
+JNIEXPORT jlong JNICALL
+Java_jau_sys_dl_UnixDynamicLinkerImpl_dlopen(JNIEnv *env, jclass _unused, jstring arg0, jint arg1) {
+ (void)_unused;
+
+ const char* _UTF8arg0 = NULL;
+ void * _res;
+#ifdef DEBUG_DLOPEN
+ DLOPEN_FPTR_TYPE dlopenFunc = NULL;
+ DBG_PRINT("XXX dlopen.0\n");
+#endif
+
+ if (arg0 != NULL) {
+ if (arg0 != NULL) {
+ _UTF8arg0 = env->GetStringUTFChars(arg0, (jboolean*)NULL);
+ if (_UTF8arg0 == NULL) {
+ env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"),
+ "Failed to get UTF-8 chars for argument \"arg0\" in native dispatcher for \"dlopen\"");
+ return 0;
+ }
+ }
+ }
+#ifdef DEBUG_DLOPEN
+ dlopenFunc = (DLOPEN_FPTR_TYPE) dlsym(RTLD_DEFAULT, "dlopen");
+ DBG_PRINT("XXX dlopen.1: lib %s, dlopen-fptr %p %p (%d)\n", _UTF8arg0, dlopen, dlopenFunc, dlopen==dlopenFunc);
+ _res = dlopen((char *) _UTF8arg0, (int) arg1);
+ DBG_PRINT("XXX dlopen.2: %p\n", _res);
+#else
+ _res = dlopen((char *) _UTF8arg0, (int) arg1);
+#endif
+ if (arg0 != NULL) {
+ env->ReleaseStringUTFChars(arg0, _UTF8arg0);
+ }
+#ifdef DEBUG_DLOPEN
+ DBG_PRINT("XXX dlopen.X\n");
+#endif
+ return (jlong) (intptr_t) _res;
+}
+
+/*
+ * Class: jau_sys_dl_UnixDynamicLinkerImpl
+ * Method: dlsym
+ * Signature: (JLjava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL
+Java_jau_sys_dl_UnixDynamicLinkerImpl_dlsym(JNIEnv *env, jclass _unused, jlong arg0, jstring arg1) {
+ (void)_unused;
+
+ const char* _UTF8arg1 = NULL;
+ void * _res;
+ if (arg1 != NULL) {
+ if (arg1 != NULL) {
+ _UTF8arg1 = env->GetStringUTFChars(arg1, (jboolean*)NULL);
+ if (_UTF8arg1 == NULL) {
+ env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"),
+ "Failed to get UTF-8 chars for argument \"arg1\" in native dispatcher for \"dlsym\"");
+ return 0;
+ }
+ }
+ }
+ _res = dlsym((void *) (intptr_t) arg0, (char *) _UTF8arg1);
+ DBG_PRINT("XXX dlsym: handle %p, symbol %s -> %p\n", (void *) (intptr_t) arg0, _UTF8arg1, _res);
+
+ if (arg1 != NULL) {
+ env->ReleaseStringUTFChars(arg1, _UTF8arg1);
+ }
+ return (jlong) (intptr_t) _res;
+}
+
diff --git a/java_jni/jni/jau/WindowsDynamicLinkerImpl_JNI.cxx b/java_jni/jni/jau/WindowsDynamicLinkerImpl_JNI.cxx
new file mode 100644
index 0000000..f9ee9a7
--- /dev/null
+++ b/java_jni/jni/jau/WindowsDynamicLinkerImpl_JNI.cxx
@@ -0,0 +1,107 @@
+/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Tue May 27 02:37:55 PDT 2008 ----! */
+
+#include <jni.h>
+#include <stdlib.h>
+
+#include <assert.h>
+
+#include "jau_sys_dl_WindowsDynamicLinkerImpl.h"
+
+ #include <windows.h>
+ /* This typedef is apparently needed for compilers before VC8,
+ and for the embedded ARM compilers we're using */
+ #if !defined(__MINGW64__) && ( (_MSC_VER < 1400) || defined(UNDER_CE) )
+ typedef int intptr_t;
+ #endif
+ /* GetProcAddress doesn't exist in A/W variants under desktop Windows */
+ #ifndef UNDER_CE
+ #define GetProcAddressA GetProcAddress
+ #endif
+
+/* Java->C glue code:
+ * Java package: jogamp.common.os.WindowsDynamicLinkerImpl
+ * Java method: int FreeLibrary(long hLibModule)
+ * C function: BOOL FreeLibrary(HANDLE hLibModule);
+ */
+JNIEXPORT jint JNICALL
+Java_jau_sys_dl_WindowsDynamicLinkerImpl_FreeLibrary(JNIEnv *env, jclass _unused, jlong hLibModule) {
+ (void)env;
+ (void)_unused;
+
+ BOOL _res;
+ _res = FreeLibrary((HANDLE) (intptr_t) hLibModule);
+ return _res;
+}
+
+
+/* Java->C glue code:
+ * Java package: jogamp.common.os.WindowsDynamicLinkerImpl
+ * Java method: int GetLastError()
+ * C function: DWORD GetLastError(void);
+ */
+JNIEXPORT jint JNICALL
+Java_jau_sys_dl_WindowsDynamicLinkerImpl_GetLastError(JNIEnv *env, jclass _unused) {
+ (void)env;
+ (void)_unused;
+
+ DWORD _res;
+ _res = GetLastError();
+ return _res;
+}
+
+
+/* Java->C glue code:
+ * Java package: jogamp.common.os.WindowsDynamicLinkerImpl
+ * Java method: long GetProcAddressA(long hModule, java.lang.String lpProcName)
+ * C function: PROC GetProcAddressA(HANDLE hModule, LPCSTR lpProcName);
+ */
+JNIEXPORT jlong JNICALL
+Java_jau_sys_dl_WindowsDynamicLinkerImpl_GetProcAddressA(JNIEnv *env, jclass _unused, jlong hModule, jstring lpProcName) {
+ (void)_unused;
+
+ const char* _strchars_lpProcName = NULL;
+ PROC _res;
+ if (lpProcName != NULL) {
+ _strchars_lpProcName = env->GetStringUTFChars(lpProcName, (jboolean*)NULL);
+ if (_strchars_lpProcName == NULL) {
+ env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"),
+ "Failed to get UTF-8 chars for argument \"lpProcName\" in native dispatcher for \"GetProcAddressA\"");
+ return 0;
+ }
+ }
+ _res = GetProcAddressA((HANDLE) (intptr_t) hModule, (LPCSTR) _strchars_lpProcName);
+ if (lpProcName != NULL) {
+ env->ReleaseStringUTFChars(lpProcName, _strchars_lpProcName);
+ }
+ return (jlong) (intptr_t) _res;
+}
+
+
+/* Java->C glue code:
+ * Java package: jogamp.common.os.WindowsDynamicLinkerImpl
+ * Java method: long LoadLibraryW(java.lang.String lpLibFileName)
+ * C function: HANDLE LoadLibraryW(LPCWSTR lpLibFileName);
+ */
+JNIEXPORT jlong JNICALL
+Java_jau_sys_dl_WindowsDynamicLinkerImpl_LoadLibraryW(JNIEnv *env, jclass _unused, jstring lpLibFileName) {
+ (void)_unused;
+
+ jchar* _strchars_lpLibFileName = NULL;
+ HANDLE _res;
+ if (lpLibFileName != NULL) {
+ _strchars_lpLibFileName = (jchar *) calloc(env->GetStringLength(lpLibFileName) + 1, sizeof(jchar));
+ if (_strchars_lpLibFileName == NULL) {
+ env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"),
+ "Could not allocate temporary buffer for copying string argument \"lpLibFileName\" in native dispatcher for \"LoadLibraryW\"");
+ return 0;
+ }
+ env->GetStringRegion(lpLibFileName, 0, env->GetStringLength(lpLibFileName), _strchars_lpLibFileName);
+ }
+ _res = LoadLibraryW((LPCWSTR) _strchars_lpLibFileName);
+ if (lpLibFileName != NULL) {
+ free((void*) _strchars_lpLibFileName);
+ }
+ return (jlong) (intptr_t) _res;
+}
+
+