src/java.base/share/native/libjava/System.c
changeset 48928 cc30928a834e
parent 48608 1dab70e20292
child 49121 10f447530d32
equal deleted inserted replaced
48927:847a988152b8 48928:cc30928a834e
   123   #error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
   123   #error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
   124 #else
   124 #else
   125   #define JAVA_SPECIFICATION_VENDOR "Oracle Corporation"
   125   #define JAVA_SPECIFICATION_VENDOR "Oracle Corporation"
   126 #endif
   126 #endif
   127 
   127 
   128 static int fmtdefault; // boolean value
       
   129 jobject fillI18nProps(JNIEnv *env, jobject props, char *baseKey,
   128 jobject fillI18nProps(JNIEnv *env, jobject props, char *baseKey,
   130                       char *platformDispVal, char *platformFmtVal,
   129                       char *platformDispVal, char *platformFmtVal,
   131                       jmethodID putID, jmethodID getPropID) {
   130                       jmethodID putID, jmethodID getPropID) {
   132     jstring jVMBaseVal = NULL;
   131     jstring jVMBaseVal = NULL;
   133 
   132 
   139         char buf[64];
   138         char buf[64];
   140         jstring jVMVal = NULL;
   139         jstring jVMVal = NULL;
   141         const char *baseVal = "";
   140         const char *baseVal = "";
   142 
   141 
   143         /* user.xxx base property */
   142         /* user.xxx base property */
   144         if (fmtdefault) {
   143         if (platformDispVal) {
   145             if (platformFmtVal) {
   144             PUTPROP(props, baseKey, platformDispVal);
   146                 PUTPROP(props, baseKey, platformFmtVal);
   145             baseVal = platformDispVal;
   147                 baseVal = platformFmtVal;
       
   148             }
       
   149         } else {
       
   150             if (platformDispVal) {
       
   151                 PUTPROP(props, baseKey, platformDispVal);
       
   152                 baseVal = platformDispVal;
       
   153             }
       
   154         }
   146         }
   155 
   147 
   156         /* user.xxx.display property */
   148         /* user.xxx.display property */
   157         jio_snprintf(buf, sizeof(buf), "%s.display", baseKey);
   149         jio_snprintf(buf, sizeof(buf), "%s.display", baseKey);
   158         GETPROP(props, buf, jVMVal);
   150         GETPROP(props, buf, jVMVal);
   399     REMOVEPROP(props, "user.country");
   391     REMOVEPROP(props, "user.country");
   400     REMOVEPROP(props, "user.variant");
   392     REMOVEPROP(props, "user.variant");
   401     REMOVEPROP(props, "file.encoding");
   393     REMOVEPROP(props, "file.encoding");
   402 
   394 
   403     ret = JVM_InitProperties(env, props);
   395     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 
   396 
   415     /* reconstruct i18n related properties */
   397     /* reconstruct i18n related properties */
   416     fillI18nProps(env, props, "user.language", sprops->display_language,
   398     fillI18nProps(env, props, "user.language", sprops->display_language,
   417         sprops->format_language, putID, getPropID);
   399         sprops->format_language, putID, getPropID);
   418     fillI18nProps(env, props, "user.script",
   400     fillI18nProps(env, props, "user.script",
   428          * Since sun_jnu_encoding is now hard-coded to UTF-8 on Mac, we don't
   410          * 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
   411          * want to use it to overwrite file.encoding
   430          */
   412          */
   431         PUTPROP(props, "file.encoding", sprops->encoding);
   413         PUTPROP(props, "file.encoding", sprops->encoding);
   432 #else
   414 #else
   433         if (fmtdefault) {
   415         PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding);
   434             PUTPROP(props, "file.encoding", sprops->encoding);
       
   435         } else {
       
   436             PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding);
       
   437         }
       
   438 #endif
   416 #endif
   439     } else {
   417     } else {
   440         (*env)->DeleteLocalRef(env, jVMVal);
   418         (*env)->DeleteLocalRef(env, jVMVal);
   441     }
   419     }
   442 
   420