author | rriggs |
Wed, 28 Nov 2018 15:53:49 -0500 | |
changeset 52724 | 0bdbf854472f |
parent 52478 | b915bd68d907 |
child 52725 | c470f977ade8 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
2 |
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
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 |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
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. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include <string.h> |
|
27 |
||
28 |
#include "jni.h" |
|
29 |
#include "jni_util.h" |
|
30 |
#include "jvm.h" |
|
31 |
#include "java_props.h" |
|
32 |
||
33 |
#include "java_lang_System.h" |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
34 |
#include "jdk_internal_util_SystemProps_Raw.h" |
2 | 35 |
|
36 |
#define OBJ "Ljava/lang/Object;" |
|
37 |
||
38 |
/* Only register the performance-critical methods */ |
|
39 |
static JNINativeMethod methods[] = { |
|
40 |
{"currentTimeMillis", "()J", (void *)&JVM_CurrentTimeMillis}, |
|
41 |
{"nanoTime", "()J", (void *)&JVM_NanoTime}, |
|
42 |
{"arraycopy", "(" OBJ "I" OBJ "II)V", (void *)&JVM_ArrayCopy}, |
|
43 |
}; |
|
44 |
||
45 |
#undef OBJ |
|
46 |
||
47 |
JNIEXPORT void JNICALL |
|
48 |
Java_java_lang_System_registerNatives(JNIEnv *env, jclass cls) |
|
49 |
{ |
|
50 |
(*env)->RegisterNatives(env, cls, |
|
51 |
methods, sizeof(methods)/sizeof(methods[0])); |
|
52 |
} |
|
53 |
||
54 |
JNIEXPORT jint JNICALL |
|
55 |
Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) |
|
56 |
{ |
|
57 |
return JVM_IHashCode(env, x); |
|
58 |
} |
|
59 |
||
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
60 |
/* VENDOR, VENDOR_URL, VENDOR_URL_BUG are set in VersionProps.java.template. */ |
2 | 61 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
62 |
/* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
63 |
* Store the UTF-8 string encoding of the value in the array |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
64 |
* at the index if the value is non-null. Store nothing if the value is null. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
65 |
* On any error, return from Java_jdk_internal_util_SystemProps_00024Raw_platformProperties. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
66 |
*/ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
67 |
#define PUTPROP(array, prop_index, val) \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
68 |
if (val != NULL) { \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
69 |
jstring jval = (*env)->NewStringUTF(env, val); \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
70 |
if (jval == NULL) \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
71 |
return NULL; \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
72 |
(*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
73 |
if ((*env)->ExceptionOccurred(env)) \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
74 |
return NULL; \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
75 |
(*env)->DeleteLocalRef(env, jval); \ |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
76 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
77 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
78 |
/* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
79 |
* Store the Platform string encoding of the value in the array |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
80 |
* at the index if the value is non-null. Store nothing if the value is null. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
81 |
* On any error, return from Java_jdk_internal_util_SystemProps_00024Raw_platformProperties. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
82 |
*/ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
83 |
#define PUTPROP_PlatformString(array, prop_index, val) \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
84 |
if (val != NULL) { \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
85 |
jstring jval = GetStringPlatform(env, val); \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
86 |
if (jval == NULL) \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
87 |
return NULL; \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
88 |
(*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
89 |
if ((*env)->ExceptionOccurred(env)) \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
90 |
return NULL; \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
91 |
(*env)->DeleteLocalRef(env, jval); \ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
92 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
93 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
94 |
/* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
95 |
* Gather the system properties and return as a String[]. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
96 |
* The first FIXED_LENGTH entries are the platform defined property values, no names. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
97 |
* The remaining array indices are alternating key/value pairs |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
98 |
* supplied by the VM including those defined on the command line |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
99 |
* using -Dkey=value that may override the platform defined value. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
100 |
* The caller is responsible for replacing platform provided values as needed. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
101 |
* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
102 |
* Class: jdk_internal_util_SystemProps_Raw |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
103 |
* Method: platformProperties |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
104 |
* Signature: ()[Ljava/lang/String; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
105 |
*/ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
106 |
JNIEXPORT jobjectArray JNICALL |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
107 |
Java_jdk_internal_util_SystemProps_00024Raw_platformProperties(JNIEnv *env, jclass cla) |
2 | 108 |
{ |
22641
e47f8892133e
8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents:
21130
diff
changeset
|
109 |
java_props_t *sprops; |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
110 |
jobject propArray = NULL; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
111 |
jclass classString; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
112 |
int nstrings = jdk_internal_util_SystemProps_Raw_FIXED_LENGTH; |
2 | 113 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
114 |
// Get the platform specific values |
22641
e47f8892133e
8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents:
21130
diff
changeset
|
115 |
sprops = GetJavaProperties(env); |
e47f8892133e
8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents:
21130
diff
changeset
|
116 |
CHECK_NULL_RETURN(sprops, NULL); |
e47f8892133e
8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents:
21130
diff
changeset
|
117 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
118 |
/* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
119 |
* !!! DO NOT call PUTPROP_PlatformString (NewStringPlatform) before this line !!! |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
120 |
*/ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
121 |
InitializeEncoding(env, sprops->sun_jnu_encoding); |
2 | 122 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
123 |
// Ensure capacity for the array and for a string for each fixed length element |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
124 |
if ((*env)->EnsureLocalCapacity(env, nstrings + 2) < 0) { |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
125 |
return NULL; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
126 |
} |
2 | 127 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
128 |
// Allocate an array of String for all the well known props |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
129 |
classString = JNU_ClassString(env); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
130 |
CHECK_NULL_RETURN(classString, NULL); |
2 | 131 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
132 |
propArray = (*env)->NewObjectArray(env, nstrings, classString, NULL); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
133 |
CHECK_NULL_RETURN(propArray, NULL); |
2 | 134 |
|
135 |
/* os properties */ |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
136 |
PUTPROP(propArray, _os_name_NDX, sprops->os_name); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
137 |
PUTPROP(propArray, _os_version_NDX, sprops->os_version); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
138 |
PUTPROP(propArray, _os_arch_NDX, sprops->os_arch); |
2 | 139 |
|
16041
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
140 |
#ifdef JDK_ARCH_ABI_PROP_NAME |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
141 |
PUTPROP(propArray, _sun_arch_abi_NDX, sprops->sun_arch_abi); |
16041
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
142 |
#endif |
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
143 |
|
2 | 144 |
/* file system properties */ |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
145 |
PUTPROP(propArray, _file_separator_NDX, sprops->file_separator); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
146 |
PUTPROP(propArray, _path_separator_NDX, sprops->path_separator); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
147 |
PUTPROP(propArray, _line_separator_NDX, sprops->line_separator); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
148 |
|
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
149 |
PUTPROP(propArray, _file_encoding_NDX, sprops->encoding); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
150 |
PUTPROP(propArray, _sun_jnu_encoding_NDX, sprops->sun_jnu_encoding); |
2 | 151 |
|
152 |
/* |
|
49292
dde7eaaa3ddc
8199756: Simplify language, country, script, and variant property initialization
rriggs
parents:
49213
diff
changeset
|
153 |
* file encoding for stdout and stderr |
2 | 154 |
*/ |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
155 |
PUTPROP(propArray, _sun_stdout_encoding_NDX, sprops->sun_stdout_encoding); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
156 |
PUTPROP(propArray, _sun_stderr_encoding_NDX, sprops->sun_stderr_encoding); |
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
9036
diff
changeset
|
157 |
|
2 | 158 |
/* unicode_encoding specifies the default endianness */ |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
159 |
PUTPROP(propArray, _sun_io_unicode_encoding_NDX, sprops->unicode_encoding); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
160 |
PUTPROP(propArray, _sun_cpu_endian_NDX, sprops->cpu_endian); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
161 |
PUTPROP(propArray, _sun_cpu_isalist_NDX, sprops->cpu_isalist); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
162 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
163 |
#ifdef MACOSX |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
164 |
PUTPROP(propArray, _java_awt_headless_NDX, sprops->awt_headless); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
165 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
166 |
/* Proxy setting properties */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
167 |
if (sprops->httpProxyEnabled) { |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
168 |
PUTPROP(propArray, _http_proxyHost_NDX, sprops->httpHost); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
169 |
PUTPROP(propArray, _http_proxyPort_NDX, sprops->httpPort); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
170 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
171 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
172 |
if (sprops->httpsProxyEnabled) { |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
173 |
PUTPROP(propArray, _https_proxyHost_NDX, sprops->httpsHost); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
174 |
PUTPROP(propArray, _https_proxyPort_NDX, sprops->httpsPort); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
175 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
176 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
177 |
if (sprops->ftpProxyEnabled) { |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
178 |
PUTPROP(propArray, _ftp_proxyHost_NDX, sprops->ftpHost); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
179 |
PUTPROP(propArray, _ftp_proxyPort_NDX, sprops->ftpPort); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
180 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
181 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
182 |
if (sprops->socksProxyEnabled) { |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
183 |
PUTPROP(propArray, _socksProxyHost_NDX, sprops->socksHost); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
184 |
PUTPROP(propArray, _socksProxyPort_NDX, sprops->socksPort); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
185 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
186 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
187 |
if (sprops->gopherProxyEnabled) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
188 |
// The gopher client is different in that it expects an 'is this set?' flag that the others don't. |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
189 |
PUTPROP(propArray, _gopherProxySet_NDX, "true"); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
190 |
PUTPROP(propArray, _gopherProxyHost_NDX, sprops->gopherHost); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
191 |
PUTPROP(propArray, _gopherProxyPort_NDX, sprops->gopherPort); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
192 |
} else { |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
193 |
PUTPROP(propArray, _gopherProxySet_NDX, "false"); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
194 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
195 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
196 |
// Mac OS X only has a single proxy exception list which applies |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
197 |
// to all protocols |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
198 |
if (sprops->exceptionList) { |
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
199 |
PUTPROP(propArray, _http_nonProxyHosts_NDX, sprops->exceptionList); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
200 |
PUTPROP(propArray, _ftp_nonProxyHosts_NDX, sprops->exceptionList); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
201 |
PUTPROP(propArray, _socksNonProxyHosts_NDX, sprops->exceptionList); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
202 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
203 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11906
diff
changeset
|
204 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
205 |
/* data model */ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
206 |
if (sizeof(sprops) == 4) { |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
207 |
sprops->data_model = "32"; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
208 |
} else if (sizeof(sprops) == 8) { |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
209 |
sprops->data_model = "64"; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
210 |
} else { |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
211 |
sprops->data_model = "unknown"; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
212 |
} |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
213 |
PUTPROP(propArray, _sun_arch_data_model_NDX, sprops->data_model); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
214 |
|
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
215 |
/* patch level */ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
216 |
PUTPROP(propArray, _sun_os_patch_level_NDX, sprops->patch_level); |
2 | 217 |
|
218 |
/* Printing properties */ |
|
219 |
/* Note: java.awt.printerjob is an implementation private property which |
|
220 |
* just happens to have a java.* name because it is referenced in |
|
6676
c8629a8bbd7d
6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents:
5506
diff
changeset
|
221 |
* a java.awt class. It is the mechanism by which the implementation |
2 | 222 |
* finds the appropriate class in the JRE for the platform. |
223 |
* It is explicitly not designed to be overridden by clients as |
|
224 |
* a way of replacing the implementation class, and in any case |
|
225 |
* the mechanism by which the class is loaded is constrained to only |
|
226 |
* find and load classes that are part of the JRE. |
|
227 |
* This property may be removed if that mechanism is redesigned |
|
228 |
*/ |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
229 |
PUTPROP(propArray, _java_awt_printerjob_NDX, sprops->printerJob); |
2 | 230 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
231 |
PUTPROP(propArray, _awt_toolkit_NDX, sprops->awt_toolkit); |
2 | 232 |
|
233 |
/* Java2D properties */ |
|
234 |
/* Note: java.awt.graphicsenv is an implementation private property which |
|
235 |
* just happens to have a java.* name because it is referenced in |
|
6676
c8629a8bbd7d
6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents:
5506
diff
changeset
|
236 |
* a java.awt class. It is the mechanism by which the implementation |
2 | 237 |
* finds the appropriate class in the JRE for the platform. |
238 |
* It is explicitly not designed to be overridden by clients as |
|
239 |
* a way of replacing the implementation class, and in any case |
|
240 |
* the mechanism by which the class is loaded is constrained to only |
|
241 |
* find and load classes that are part of the JRE. |
|
242 |
* This property may be removed if that mechanism is redesigned |
|
243 |
*/ |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
244 |
PUTPROP(propArray, _java_awt_graphicsenv_NDX, sprops->graphics_env); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
245 |
PUTPROP_PlatformString(propArray, _sun_java2d_fontpath_NDX, sprops->font_dir); |
2 | 246 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
247 |
/* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
248 |
* The sun.desktop property is currently only set for Gnome and Windows desktops. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
249 |
*/ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
250 |
PUTPROP(propArray, _sun_desktop_NDX, sprops->desktop); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
251 |
|
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
252 |
PUTPROP_PlatformString(propArray, _java_io_tmpdir_NDX, sprops->tmp_dir); |
2 | 253 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
254 |
PUTPROP_PlatformString(propArray, _user_name_NDX, sprops->user_name); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
255 |
PUTPROP_PlatformString(propArray, _user_home_NDX, sprops->user_home); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
256 |
PUTPROP_PlatformString(propArray, _user_dir_NDX, sprops->user_dir); |
2 | 257 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
258 |
/* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
259 |
* Set i18n related property fields from platform. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
260 |
*/ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
261 |
PUTPROP(propArray, _display_language_NDX, sprops->display_language); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
262 |
PUTPROP(propArray, _display_script_NDX, sprops->display_script); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
263 |
PUTPROP(propArray, _display_country_NDX, sprops->display_country); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
264 |
PUTPROP(propArray, _display_variant_NDX, sprops->display_variant); |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
265 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
266 |
PUTPROP(propArray, _format_language_NDX, sprops->format_language); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
267 |
PUTPROP(propArray, _format_script_NDX, sprops->format_script); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
268 |
PUTPROP(propArray, _format_country_NDX, sprops->format_country); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
269 |
PUTPROP(propArray, _format_variant_NDX, sprops->format_variant); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
270 |
|
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
271 |
return propArray; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
272 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
273 |
|
52724
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
274 |
/* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
275 |
* Gather the VM and command line properties and return as a String[]. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
276 |
* The array indices are alternating key/value pairs |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
277 |
* supplied by the VM including those defined on the command line |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
278 |
* using -Dkey=value that may override the platform defined value. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
279 |
* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
280 |
* Note: The platform encoding must have been set. |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
281 |
* |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
282 |
* Class: jdk_internal_util_SystemProps_Raw |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
283 |
* Method: vmProperties |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
284 |
* Signature: ()[Ljava/lang/String; |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
285 |
*/ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
286 |
JNIEXPORT jobjectArray JNICALL |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
287 |
Java_jdk_internal_util_SystemProps_00024Raw_vmProperties(JNIEnv *env, jclass cla) |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
288 |
{ |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
289 |
jobjectArray cmdProps = JVM_GetProperties(env); |
0bdbf854472f
4947890: Minimize JNI upcalls in system-properties initialization
rriggs
parents:
52478
diff
changeset
|
290 |
return cmdProps; |
2 | 291 |
} |
292 |
||
293 |
/* |
|
294 |
* The following three functions implement setter methods for |
|
295 |
* java.lang.System.{in, out, err}. They are natively implemented |
|
296 |
* because they violate the semantics of the language (i.e. set final |
|
297 |
* variable). |
|
298 |
*/ |
|
299 |
JNIEXPORT void JNICALL |
|
300 |
Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream) |
|
301 |
{ |
|
302 |
jfieldID fid = |
|
303 |
(*env)->GetStaticFieldID(env,cla,"in","Ljava/io/InputStream;"); |
|
304 |
if (fid == 0) |
|
305 |
return; |
|
306 |
(*env)->SetStaticObjectField(env,cla,fid,stream); |
|
307 |
} |
|
308 |
||
309 |
JNIEXPORT void JNICALL |
|
310 |
Java_java_lang_System_setOut0(JNIEnv *env, jclass cla, jobject stream) |
|
311 |
{ |
|
312 |
jfieldID fid = |
|
313 |
(*env)->GetStaticFieldID(env,cla,"out","Ljava/io/PrintStream;"); |
|
314 |
if (fid == 0) |
|
315 |
return; |
|
316 |
(*env)->SetStaticObjectField(env,cla,fid,stream); |
|
317 |
} |
|
318 |
||
319 |
JNIEXPORT void JNICALL |
|
320 |
Java_java_lang_System_setErr0(JNIEnv *env, jclass cla, jobject stream) |
|
321 |
{ |
|
322 |
jfieldID fid = |
|
323 |
(*env)->GetStaticFieldID(env,cla,"err","Ljava/io/PrintStream;"); |
|
324 |
if (fid == 0) |
|
325 |
return; |
|
326 |
(*env)->SetStaticObjectField(env,cla,fid,stream); |
|
327 |
} |
|
328 |
||
329 |
static void cpchars(jchar *dst, char *src, int n) |
|
330 |
{ |
|
331 |
int i; |
|
332 |
for (i = 0; i < n; i++) { |
|
333 |
dst[i] = src[i]; |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
JNIEXPORT jstring JNICALL |
|
338 |
Java_java_lang_System_mapLibraryName(JNIEnv *env, jclass ign, jstring libname) |
|
339 |
{ |
|
340 |
int len; |
|
341 |
int prefix_len = (int) strlen(JNI_LIB_PREFIX); |
|
342 |
int suffix_len = (int) strlen(JNI_LIB_SUFFIX); |
|
343 |
||
344 |
jchar chars[256]; |
|
345 |
if (libname == NULL) { |
|
346 |
JNU_ThrowNullPointerException(env, 0); |
|
347 |
return NULL; |
|
348 |
} |
|
349 |
len = (*env)->GetStringLength(env, libname); |
|
350 |
if (len > 240) { |
|
351 |
JNU_ThrowIllegalArgumentException(env, "name too long"); |
|
352 |
return NULL; |
|
353 |
} |
|
354 |
cpchars(chars, JNI_LIB_PREFIX, prefix_len); |
|
355 |
(*env)->GetStringRegion(env, libname, 0, len, chars + prefix_len); |
|
356 |
len += prefix_len; |
|
357 |
cpchars(chars + len, JNI_LIB_SUFFIX, suffix_len); |
|
358 |
len += suffix_len; |
|
359 |
||
360 |
return (*env)->NewString(env, chars, len); |
|
361 |
} |