author | alanb |
Fri, 24 Jan 2014 11:50:33 +0000 | |
changeset 22572 | 0680f54048ba |
parent 16479 | d845c18d13f2 |
child 22938 | dde13f2c082d |
permissions | -rw-r--r-- |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
1 |
/* |
16479
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
4 |
* |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
10 |
* |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
15 |
* accompanied this code). |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
16 |
* |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
24 |
*/ |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
25 |
|
22572
0680f54048ba
8032456: vm/jni/Miscellaneous/misc001/misc00101m1/misc00101m1.html failing on OS X
alanb
parents:
16479
diff
changeset
|
26 |
#include <string.h> |
0680f54048ba
8032456: vm/jni/Miscellaneous/misc001/misc00101m1/misc00101m1.html failing on OS X
alanb
parents:
16479
diff
changeset
|
27 |
|
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
28 |
#include "jni.h" |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
29 |
#include "jni_util.h" |
16479
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
30 |
#include "dlfcn.h" |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
31 |
|
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
32 |
jstring nativeNewStringPlatform(JNIEnv *env, const char *str) { |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
33 |
return NULL; |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
34 |
} |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
35 |
|
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
36 |
char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) { |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
37 |
return NULL; |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
diff
changeset
|
38 |
} |
16479
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
39 |
|
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
40 |
void* getProcessHandle() { |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
41 |
static void *procHandle = NULL; |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
42 |
if (procHandle != NULL) { |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
43 |
return procHandle; |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
44 |
} |
22572
0680f54048ba
8032456: vm/jni/Miscellaneous/misc001/misc00101m1/misc00101m1.html failing on OS X
alanb
parents:
16479
diff
changeset
|
45 |
#ifdef __APPLE__ |
0680f54048ba
8032456: vm/jni/Miscellaneous/misc001/misc00101m1/misc00101m1.html failing on OS X
alanb
parents:
16479
diff
changeset
|
46 |
procHandle = (void*)dlopen(NULL, RTLD_FIRST); |
0680f54048ba
8032456: vm/jni/Miscellaneous/misc001/misc00101m1/misc00101m1.html failing on OS X
alanb
parents:
16479
diff
changeset
|
47 |
#else |
16479
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
48 |
procHandle = (void*)dlopen(NULL, RTLD_LAZY); |
22572
0680f54048ba
8032456: vm/jni/Miscellaneous/misc001/misc00101m1/misc00101m1.html failing on OS X
alanb
parents:
16479
diff
changeset
|
49 |
#endif |
16479
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
50 |
return procHandle; |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
51 |
} |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
52 |
|
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
53 |
void buildJniFunctionName(const char *sym, const char *cname, |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
54 |
char *jniEntryName) { |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
55 |
strcpy(jniEntryName, sym); |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
56 |
if (cname != NULL) { |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
57 |
strcat(jniEntryName, "_"); |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
58 |
strcat(jniEntryName, cname); |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
59 |
} |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
60 |
} |
d845c18d13f2
8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents:
5506
diff
changeset
|
61 |