src/solaris/native/common/jni_util_md.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -23,13 +23,48 @@
* questions.
*/
#include "jni.h"
#include "jni_util.h"
+#include "dlfcn.h"
+#include <stdlib.h>
+#include <string.h>
jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
return NULL;
}
char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
return NULL;
}
+
+void* getProcessHandle() {
+ static void *procHandle = NULL;
+ if (procHandle != NULL) {
+ return procHandle;
+ }
+ procHandle = (void*)dlopen(NULL, RTLD_LAZY);
+ return procHandle;
+}
+
+char *buildJniFunctionName(JNIEnv *env, const char *sym, const char *cname) {
+ int len;
+ char *jniFunctionName;
+ // cname + sym + '_' + '\0'
+ if ((len = (cname != NULL ? strlen(cname) : 0) + strlen(sym) + 2) >
+ FILENAME_MAX) {
+ JNU_ThrowInternalError(env, "Filename for native library too long");
+ return NULL;
+ }
+ jniFunctionName = malloc(len);
+ if (jniFunctionName == NULL) {
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return NULL;
+ }
+ strcpy(jniFunctionName, sym);
+ if (cname != NULL) {
+ strcat(jniFunctionName, "_");
+ strcat(jniFunctionName, cname);
+ }
+ return jniFunctionName;
+}
+