365 /* Check the compatibility flag */ 366 GETPROP(props, "sun.locale.formatasdefault", jVMVal); 367 if (jVMVal) { 368 const char * val = (*env)->GetStringUTFChars(env, jVMVal, 0); 369 fmtdefault = !strcmp(val, "true"); 370 (*env)->ReleaseStringUTFChars(env, jVMVal, val); 371 (*env)->DeleteLocalRef(env, jVMVal); 372 } 373 374 /* reconstruct i18n related properties */ 375 fillI18nProps(env, props, "user.language", sprops->display_language, 376 sprops->format_language, putID, getPropID); 377 fillI18nProps(env, props, "user.script", 378 sprops->display_script, sprops->format_script, putID, getPropID); 379 fillI18nProps(env, props, "user.country", 380 sprops->display_country, sprops->format_country, putID, getPropID); 381 fillI18nProps(env, props, "user.variant", 382 sprops->display_variant, sprops->format_variant, putID, getPropID); 383 GETPROP(props, "file.encoding", jVMVal); 384 if (jVMVal == NULL) { 385 if (fmtdefault) { 386 PUTPROP(props, "file.encoding", sprops->encoding); 387 } else { 388 PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding); 389 } 390 } else { 391 (*env)->DeleteLocalRef(env, jVMVal); 392 } 393 394 return ret; 395 } 396 397 /* 398 * The following three functions implement setter methods for 399 * java.lang.System.{in, out, err}. They are natively implemented 400 * because they violate the semantics of the language (i.e. set final 401 * variable). 402 */ 403 JNIEXPORT void JNICALL 404 Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream) 405 { 406 jfieldID fid = 407 (*env)->GetStaticFieldID(env,cla,"in","Ljava/io/InputStream;"); 408 if (fid == 0) 409 return; | 365 /* Check the compatibility flag */ 366 GETPROP(props, "sun.locale.formatasdefault", jVMVal); 367 if (jVMVal) { 368 const char * val = (*env)->GetStringUTFChars(env, jVMVal, 0); 369 fmtdefault = !strcmp(val, "true"); 370 (*env)->ReleaseStringUTFChars(env, jVMVal, val); 371 (*env)->DeleteLocalRef(env, jVMVal); 372 } 373 374 /* reconstruct i18n related properties */ 375 fillI18nProps(env, props, "user.language", sprops->display_language, 376 sprops->format_language, putID, getPropID); 377 fillI18nProps(env, props, "user.script", 378 sprops->display_script, sprops->format_script, putID, getPropID); 379 fillI18nProps(env, props, "user.country", 380 sprops->display_country, sprops->format_country, putID, getPropID); 381 fillI18nProps(env, props, "user.variant", 382 sprops->display_variant, sprops->format_variant, putID, getPropID); 383 GETPROP(props, "file.encoding", jVMVal); 384 if (jVMVal == NULL) { 385 #ifdef MACOSX 386 /* 387 * Since sun_jnu_encoding is now hard-coded to UTF-8 on Mac, we don't 388 * want to use it to overwrite file.encoding 389 */ 390 PUTPROP(props, "file.encoding", sprops->encoding); 391 #else 392 if (fmtdefault) { 393 PUTPROP(props, "file.encoding", sprops->encoding); 394 } else { 395 PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding); 396 } 397 #endif 398 } else { 399 (*env)->DeleteLocalRef(env, jVMVal); 400 } 401 402 return ret; 403 } 404 405 /* 406 * The following three functions implement setter methods for 407 * java.lang.System.{in, out, err}. They are natively implemented 408 * because they violate the semantics of the language (i.e. set final 409 * variable). 410 */ 411 JNIEXPORT void JNICALL 412 Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream) 413 { 414 jfieldID fid = 415 (*env)->GetStaticFieldID(env,cla,"in","Ljava/io/InputStream;"); 416 if (fid == 0) 417 return; |