108 (*env)->DeleteLocalRef(env, jkey); \
109 } else ((void) 0)
110
111 /* Third party may overwrite these values. */
112 #ifndef VENDOR
113 #define VENDOR "Oracle Corporation"
114 #endif
115 #ifndef VENDOR_URL
116 #define VENDOR_URL "http://java.oracle.com/"
117 #endif
118 #ifndef VENDOR_URL_BUG
119 #define VENDOR_URL_BUG "http://bugreport.java.com/bugreport/"
120 #endif
121
122 #ifdef JAVA_SPECIFICATION_VENDOR /* Third party may NOT overwrite this. */
123 #error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
124 #else
125 #define JAVA_SPECIFICATION_VENDOR "Oracle Corporation"
126 #endif
127
128 static int fmtdefault; // boolean value
129 jobject fillI18nProps(JNIEnv *env, jobject props, char *baseKey,
130 char *platformDispVal, char *platformFmtVal,
131 jmethodID putID, jmethodID getPropID) {
132 jstring jVMBaseVal = NULL;
133
134 GETPROP(props, baseKey, jVMBaseVal);
135 if (jVMBaseVal) {
136 // user specified the base property. there's nothing to do here.
137 (*env)->DeleteLocalRef(env, jVMBaseVal);
138 } else {
139 char buf[64];
140 jstring jVMVal = NULL;
141 const char *baseVal = "";
142
143 /* user.xxx base property */
144 if (fmtdefault) {
145 if (platformFmtVal) {
146 PUTPROP(props, baseKey, platformFmtVal);
147 baseVal = platformFmtVal;
148 }
149 } else {
150 if (platformDispVal) {
151 PUTPROP(props, baseKey, platformDispVal);
152 baseVal = platformDispVal;
153 }
154 }
155
156 /* user.xxx.display property */
157 jio_snprintf(buf, sizeof(buf), "%s.display", baseKey);
158 GETPROP(props, buf, jVMVal);
159 if (jVMVal == NULL) {
160 if (platformDispVal && (strcmp(baseVal, platformDispVal) != 0)) {
161 PUTPROP(props, buf, platformDispVal);
162 }
163 } else {
164 (*env)->DeleteLocalRef(env, jVMVal);
165 }
166
167 /* user.xxx.format property */
168 jio_snprintf(buf, sizeof(buf), "%s.format", baseKey);
169 GETPROP(props, buf, jVMVal);
170 if (jVMVal == NULL) {
171 if (platformFmtVal && (strcmp(baseVal, platformFmtVal) != 0)) {
172 PUTPROP(props, buf, platformFmtVal);
173 }
174 } else {
385 /* This is a sun. property as it is currently only set for Gnome and
386 * Windows desktops.
387 */
388 if (sprops->desktop != NULL) {
389 PUTPROP(props, "sun.desktop", sprops->desktop);
390 }
391
392 /*
393 * unset "user.language", "user.script", "user.country", and "user.variant"
394 * in order to tell whether the command line option "-DXXXX=YYYY" is
395 * specified or not. They will be reset in fillI18nProps() below.
396 */
397 REMOVEPROP(props, "user.language");
398 REMOVEPROP(props, "user.script");
399 REMOVEPROP(props, "user.country");
400 REMOVEPROP(props, "user.variant");
401 REMOVEPROP(props, "file.encoding");
402
403 ret = JVM_InitProperties(env, props);
404
405 /* Check the compatibility flag */
406 GETPROP(props, "sun.locale.formatasdefault", jVMVal);
407 if (jVMVal) {
408 const char * val = (*env)->GetStringUTFChars(env, jVMVal, 0);
409 CHECK_NULL_RETURN(val, NULL);
410 fmtdefault = !strcmp(val, "true");
411 (*env)->ReleaseStringUTFChars(env, jVMVal, val);
412 (*env)->DeleteLocalRef(env, jVMVal);
413 }
414
415 /* reconstruct i18n related properties */
416 fillI18nProps(env, props, "user.language", sprops->display_language,
417 sprops->format_language, putID, getPropID);
418 fillI18nProps(env, props, "user.script",
419 sprops->display_script, sprops->format_script, putID, getPropID);
420 fillI18nProps(env, props, "user.country",
421 sprops->display_country, sprops->format_country, putID, getPropID);
422 fillI18nProps(env, props, "user.variant",
423 sprops->display_variant, sprops->format_variant, putID, getPropID);
424 GETPROP(props, "file.encoding", jVMVal);
425 if (jVMVal == NULL) {
426 #ifdef MACOSX
427 /*
428 * Since sun_jnu_encoding is now hard-coded to UTF-8 on Mac, we don't
429 * want to use it to overwrite file.encoding
430 */
431 PUTPROP(props, "file.encoding", sprops->encoding);
432 #else
433 if (fmtdefault) {
434 PUTPROP(props, "file.encoding", sprops->encoding);
435 } else {
436 PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding);
437 }
438 #endif
439 } else {
440 (*env)->DeleteLocalRef(env, jVMVal);
441 }
442
443 return ret;
444 }
445
446 /*
447 * The following three functions implement setter methods for
448 * java.lang.System.{in, out, err}. They are natively implemented
449 * because they violate the semantics of the language (i.e. set final
450 * variable).
451 */
452 JNIEXPORT void JNICALL
453 Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream)
454 {
455 jfieldID fid =
456 (*env)->GetStaticFieldID(env,cla,"in","Ljava/io/InputStream;");
457 if (fid == 0)
|
108 (*env)->DeleteLocalRef(env, jkey); \
109 } else ((void) 0)
110
111 /* Third party may overwrite these values. */
112 #ifndef VENDOR
113 #define VENDOR "Oracle Corporation"
114 #endif
115 #ifndef VENDOR_URL
116 #define VENDOR_URL "http://java.oracle.com/"
117 #endif
118 #ifndef VENDOR_URL_BUG
119 #define VENDOR_URL_BUG "http://bugreport.java.com/bugreport/"
120 #endif
121
122 #ifdef JAVA_SPECIFICATION_VENDOR /* Third party may NOT overwrite this. */
123 #error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
124 #else
125 #define JAVA_SPECIFICATION_VENDOR "Oracle Corporation"
126 #endif
127
128 jobject fillI18nProps(JNIEnv *env, jobject props, char *baseKey,
129 char *platformDispVal, char *platformFmtVal,
130 jmethodID putID, jmethodID getPropID) {
131 jstring jVMBaseVal = NULL;
132
133 GETPROP(props, baseKey, jVMBaseVal);
134 if (jVMBaseVal) {
135 // user specified the base property. there's nothing to do here.
136 (*env)->DeleteLocalRef(env, jVMBaseVal);
137 } else {
138 char buf[64];
139 jstring jVMVal = NULL;
140 const char *baseVal = "";
141
142 /* user.xxx base property */
143 if (platformDispVal) {
144 PUTPROP(props, baseKey, platformDispVal);
145 baseVal = platformDispVal;
146 }
147
148 /* user.xxx.display property */
149 jio_snprintf(buf, sizeof(buf), "%s.display", baseKey);
150 GETPROP(props, buf, jVMVal);
151 if (jVMVal == NULL) {
152 if (platformDispVal && (strcmp(baseVal, platformDispVal) != 0)) {
153 PUTPROP(props, buf, platformDispVal);
154 }
155 } else {
156 (*env)->DeleteLocalRef(env, jVMVal);
157 }
158
159 /* user.xxx.format property */
160 jio_snprintf(buf, sizeof(buf), "%s.format", baseKey);
161 GETPROP(props, buf, jVMVal);
162 if (jVMVal == NULL) {
163 if (platformFmtVal && (strcmp(baseVal, platformFmtVal) != 0)) {
164 PUTPROP(props, buf, platformFmtVal);
165 }
166 } else {
377 /* This is a sun. property as it is currently only set for Gnome and
378 * Windows desktops.
379 */
380 if (sprops->desktop != NULL) {
381 PUTPROP(props, "sun.desktop", sprops->desktop);
382 }
383
384 /*
385 * unset "user.language", "user.script", "user.country", and "user.variant"
386 * in order to tell whether the command line option "-DXXXX=YYYY" is
387 * specified or not. They will be reset in fillI18nProps() below.
388 */
389 REMOVEPROP(props, "user.language");
390 REMOVEPROP(props, "user.script");
391 REMOVEPROP(props, "user.country");
392 REMOVEPROP(props, "user.variant");
393 REMOVEPROP(props, "file.encoding");
394
395 ret = JVM_InitProperties(env, props);
396
397 /* reconstruct i18n related properties */
398 fillI18nProps(env, props, "user.language", sprops->display_language,
399 sprops->format_language, putID, getPropID);
400 fillI18nProps(env, props, "user.script",
401 sprops->display_script, sprops->format_script, putID, getPropID);
402 fillI18nProps(env, props, "user.country",
403 sprops->display_country, sprops->format_country, putID, getPropID);
404 fillI18nProps(env, props, "user.variant",
405 sprops->display_variant, sprops->format_variant, putID, getPropID);
406 GETPROP(props, "file.encoding", jVMVal);
407 if (jVMVal == NULL) {
408 #ifdef MACOSX
409 /*
410 * Since sun_jnu_encoding is now hard-coded to UTF-8 on Mac, we don't
411 * want to use it to overwrite file.encoding
412 */
413 PUTPROP(props, "file.encoding", sprops->encoding);
414 #else
415 PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding);
416 #endif
417 } else {
418 (*env)->DeleteLocalRef(env, jVMVal);
419 }
420
421 return ret;
422 }
423
424 /*
425 * The following three functions implement setter methods for
426 * java.lang.System.{in, out, err}. They are natively implemented
427 * because they violate the semantics of the language (i.e. set final
428 * variable).
429 */
430 JNIEXPORT void JNICALL
431 Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream)
432 {
433 jfieldID fid =
434 (*env)->GetStaticFieldID(env,cla,"in","Ljava/io/InputStream;");
435 if (fid == 0)
|