src/java.base/share/native/libjava/System.c
changeset 52724 0bdbf854472f
parent 52478 b915bd68d907
child 52725 c470f977ade8
equal deleted inserted replaced
52723:f24ae8376e71 52724:0bdbf854472f
     1 /*
     1 /*
     2  * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    29 #include "jni_util.h"
    29 #include "jni_util.h"
    30 #include "jvm.h"
    30 #include "jvm.h"
    31 #include "java_props.h"
    31 #include "java_props.h"
    32 
    32 
    33 #include "java_lang_System.h"
    33 #include "java_lang_System.h"
       
    34 #include "jdk_internal_util_SystemProps_Raw.h"
    34 
    35 
    35 #define OBJ "Ljava/lang/Object;"
    36 #define OBJ "Ljava/lang/Object;"
    36 
    37 
    37 /* Only register the performance-critical methods */
    38 /* Only register the performance-critical methods */
    38 static JNINativeMethod methods[] = {
    39 static JNINativeMethod methods[] = {
    54 Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
    55 Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
    55 {
    56 {
    56     return JVM_IHashCode(env, x);
    57     return JVM_IHashCode(env, x);
    57 }
    58 }
    58 
    59 
    59 #define PUTPROP(props, key, val)                                     \
    60 /* VENDOR, VENDOR_URL, VENDOR_URL_BUG are set in VersionProps.java.template. */
    60     if (1) {                                                         \
    61 
    61         jstring jkey, jval;                                          \
    62 /*
    62         jobject r;                                                   \
    63  * Store the UTF-8 string encoding of the value in the array
    63         jkey = (*env)->NewStringUTF(env, key);                       \
    64  * at the index if the value is non-null.  Store nothing if the value is null.
    64         if (jkey == NULL) return NULL;                               \
    65  * On any error, return from Java_jdk_internal_util_SystemProps_00024Raw_platformProperties.
    65         jval = (*env)->NewStringUTF(env, val);                       \
    66  */
    66         if (jval == NULL) return NULL;                               \
    67 #define PUTPROP(array, prop_index, val)                    \
    67         r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
    68     if (val != NULL) {                                     \
    68         if ((*env)->ExceptionOccurred(env)) return NULL;             \
    69         jstring jval = (*env)->NewStringUTF(env, val);     \
    69         (*env)->DeleteLocalRef(env, jkey);                           \
    70         if (jval == NULL)                                  \
    70         (*env)->DeleteLocalRef(env, jval);                           \
    71             return NULL;                                   \
    71         (*env)->DeleteLocalRef(env, r);                              \
    72         (*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \
    72     } else ((void) 0)
    73         if ((*env)->ExceptionOccurred(env))                \
    73 
    74             return NULL;                                   \
    74 /*  "key" is a char type string with only ASCII character in it.
    75         (*env)->DeleteLocalRef(env, jval);                 \
    75     "val" is a nchar (typedefed in java_props.h) type string  */
    76     }
    76 
    77 
    77 #define PUTPROP_ForPlatformNString(props, key, val)                  \
    78 /*
    78     if (1) {                                                         \
    79  * Store the Platform string encoding of the value in the array
    79         jstring jkey, jval;                                          \
    80  * at the index if the value is non-null.  Store nothing if the value is null.
    80         jobject r;                                                   \
    81  * On any error, return from Java_jdk_internal_util_SystemProps_00024Raw_platformProperties.
    81         jkey = (*env)->NewStringUTF(env, key);                       \
    82  */
    82         if (jkey == NULL) return NULL;                               \
    83 #define PUTPROP_PlatformString(array, prop_index, val)     \
    83         jval = GetStringPlatform(env, val);                          \
    84     if (val != NULL) {                                     \
    84         if (jval == NULL) return NULL;                               \
    85         jstring jval = GetStringPlatform(env, val);        \
    85         r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
    86         if (jval == NULL)                                  \
    86         if ((*env)->ExceptionOccurred(env)) return NULL;             \
    87             return NULL;                                   \
    87         (*env)->DeleteLocalRef(env, jkey);                           \
    88         (*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \
    88         (*env)->DeleteLocalRef(env, jval);                           \
    89         if ((*env)->ExceptionOccurred(env))                \
    89         (*env)->DeleteLocalRef(env, r);                              \
    90             return NULL;                                   \
    90     } else ((void) 0)
    91         (*env)->DeleteLocalRef(env, jval);                 \
    91 #define REMOVEPROP(props, key)                                    \
    92     }
    92     if (1) {                                                      \
    93 
    93         jstring jkey;                                             \
    94 /*
    94         jobject r;                                                \
    95  * Gather the system properties and return as a String[].
    95         jkey = JNU_NewStringPlatform(env, key);                   \
    96  * The first FIXED_LENGTH entries are the platform defined property values, no names.
    96         if (jkey == NULL) return NULL;                            \
    97  * The remaining array indices are alternating key/value pairs
    97         r = (*env)->CallObjectMethod(env, props, removeID, jkey); \
    98  * supplied by the VM including those defined on the command line
    98         if ((*env)->ExceptionOccurred(env)) return NULL;          \
    99  * using -Dkey=value that may override the platform defined value.
    99         (*env)->DeleteLocalRef(env, jkey);                        \
   100  * The caller is responsible for replacing platform provided values as needed.
   100         (*env)->DeleteLocalRef(env, r);                           \
   101  *
   101     } else ((void) 0)
   102  * Class:     jdk_internal_util_SystemProps_Raw
   102 #define GETPROP(props, key, jret)                                     \
   103  * Method:    platformProperties
   103     if (1) {                                                          \
   104  * Signature: ()[Ljava/lang/String;
   104         jstring jkey = JNU_NewStringPlatform(env, key);               \
   105  */
   105         if (jkey == NULL) return NULL;                                \
   106 JNIEXPORT jobjectArray JNICALL
   106         jret = (*env)->CallObjectMethod(env, props, getPropID, jkey); \
   107 Java_jdk_internal_util_SystemProps_00024Raw_platformProperties(JNIEnv *env, jclass cla)
   107         if ((*env)->ExceptionOccurred(env)) return NULL;              \
   108 {
   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 {
       
   167             (*env)->DeleteLocalRef(env, jVMVal);
       
   168         }
       
   169     }
       
   170 
       
   171     return NULL;
       
   172 }
       
   173 
       
   174 JNIEXPORT jobject JNICALL
       
   175 Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
       
   176 {
       
   177     char buf[128];
       
   178     java_props_t *sprops;
   109     java_props_t *sprops;
   179     jmethodID putID, removeID, getPropID;
   110     jobject propArray = NULL;
   180     jobject ret = NULL;
   111     jclass classString;
   181     jstring jVMVal = NULL;
   112     int nstrings = jdk_internal_util_SystemProps_Raw_FIXED_LENGTH;
   182 
   113 
   183     if ((*env)->EnsureLocalCapacity(env, 50) < 0) {
   114     // Get the platform specific values
   184         return NULL;
       
   185     }
       
   186     sprops = GetJavaProperties(env);
   115     sprops = GetJavaProperties(env);
   187     CHECK_NULL_RETURN(sprops, NULL);
   116     CHECK_NULL_RETURN(sprops, NULL);
   188 
   117 
   189     putID = (*env)->GetMethodID(env,
   118     /*
   190                                 (*env)->GetObjectClass(env, props),
   119      * !!! DO NOT call PUTPROP_PlatformString (NewStringPlatform) before this line !!!
   191                                 "put",
   120      */
   192             "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
   121     InitializeEncoding(env, sprops->sun_jnu_encoding);
   193     CHECK_NULL_RETURN(putID, NULL);
   122 
   194 
   123     // Ensure capacity for the array and for a string for each fixed length element
   195     removeID = (*env)->GetMethodID(env,
   124     if ((*env)->EnsureLocalCapacity(env, nstrings + 2) < 0) {
   196                                    (*env)->GetObjectClass(env, props),
   125         return NULL;
   197                                    "remove",
   126     }
   198             "(Ljava/lang/Object;)Ljava/lang/Object;");
   127 
   199     CHECK_NULL_RETURN(removeID, NULL);
   128     // Allocate an array of String for all the well known props
   200 
   129     classString = JNU_ClassString(env);
   201     getPropID = (*env)->GetMethodID(env,
   130     CHECK_NULL_RETURN(classString, NULL);
   202                                     (*env)->GetObjectClass(env, props),
   131 
   203                                     "getProperty",
   132     propArray = (*env)->NewObjectArray(env, nstrings, classString, NULL);
   204             "(Ljava/lang/String;)Ljava/lang/String;");
   133     CHECK_NULL_RETURN(propArray, NULL);
   205     CHECK_NULL_RETURN(getPropID, NULL);
   134 
   206 
   135     /* os properties */
   207     PUTPROP(props, "java.specification.version",
   136     PUTPROP(propArray, _os_name_NDX, sprops->os_name);
   208             VERSION_SPECIFICATION);
   137     PUTPROP(propArray, _os_version_NDX, sprops->os_version);
   209     PUTPROP(props, "java.specification.name",
   138     PUTPROP(propArray, _os_arch_NDX, sprops->os_arch);
   210             "Java Platform API Specification");
   139 
   211     PUTPROP(props, "java.specification.vendor",
   140 #ifdef JDK_ARCH_ABI_PROP_NAME
   212             JAVA_SPECIFICATION_VENDOR);
   141     PUTPROP(propArray, _sun_arch_abi_NDX, sprops->sun_arch_abi);
   213 
       
   214     PUTPROP(props, "java.vendor", VENDOR);
       
   215     PUTPROP(props, "java.vendor.url", VENDOR_URL);
       
   216     PUTPROP(props, "java.vendor.url.bug", VENDOR_URL_BUG);
       
   217 
       
   218     jio_snprintf(buf, sizeof(buf), "%d.%d", JVM_CLASSFILE_MAJOR_VERSION,
       
   219                                             JVM_CLASSFILE_MINOR_VERSION);
       
   220     PUTPROP(props, "java.class.version", buf);
       
   221 
       
   222     if (sprops->awt_toolkit) {
       
   223         PUTPROP(props, "awt.toolkit", sprops->awt_toolkit);
       
   224     }
       
   225 #ifdef MACOSX
       
   226     if (sprops->awt_headless) {
       
   227         PUTPROP(props, "java.awt.headless", sprops->awt_headless);
       
   228     }
       
   229 #endif
   142 #endif
   230 
   143 
   231     /* os properties */
       
   232     PUTPROP(props, "os.name", sprops->os_name);
       
   233     PUTPROP(props, "os.version", sprops->os_version);
       
   234     PUTPROP(props, "os.arch", sprops->os_arch);
       
   235 
       
   236 #ifdef JDK_ARCH_ABI_PROP_NAME
       
   237     PUTPROP(props, "sun.arch.abi", sprops->sun_arch_abi);
       
   238 #endif
       
   239 
       
   240     /* file system properties */
   144     /* file system properties */
   241     PUTPROP(props, "file.separator", sprops->file_separator);
   145     PUTPROP(propArray, _file_separator_NDX, sprops->file_separator);
   242     PUTPROP(props, "path.separator", sprops->path_separator);
   146     PUTPROP(propArray, _path_separator_NDX, sprops->path_separator);
   243     PUTPROP(props, "line.separator", sprops->line_separator);
   147     PUTPROP(propArray, _line_separator_NDX, sprops->line_separator);
       
   148 
       
   149     PUTPROP(propArray, _file_encoding_NDX, sprops->encoding);
       
   150     PUTPROP(propArray, _sun_jnu_encoding_NDX, sprops->sun_jnu_encoding);
   244 
   151 
   245     /*
   152     /*
   246      * file encoding for stdout and stderr
   153      * file encoding for stdout and stderr
   247      */
   154      */
   248     if (sprops->sun_stdout_encoding != NULL) {
   155     PUTPROP(propArray, _sun_stdout_encoding_NDX, sprops->sun_stdout_encoding);
   249         PUTPROP(props, "sun.stdout.encoding", sprops->sun_stdout_encoding);
   156     PUTPROP(propArray, _sun_stderr_encoding_NDX, sprops->sun_stderr_encoding);
   250     }
       
   251     if (sprops->sun_stderr_encoding != NULL) {
       
   252         PUTPROP(props, "sun.stderr.encoding", sprops->sun_stderr_encoding);
       
   253     }
       
   254 
   157 
   255     /* unicode_encoding specifies the default endianness */
   158     /* unicode_encoding specifies the default endianness */
   256     PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
   159     PUTPROP(propArray, _sun_io_unicode_encoding_NDX, sprops->unicode_encoding);
   257     if (sprops->cpu_isalist  != NULL) {
   160     PUTPROP(propArray, _sun_cpu_endian_NDX, sprops->cpu_endian);
   258         // leave undefined if none
   161     PUTPROP(propArray, _sun_cpu_isalist_NDX, sprops->cpu_isalist);
   259         PUTPROP(props, "sun.cpu.isalist", sprops->cpu_isalist);
       
   260     }
       
   261     PUTPROP(props, "sun.cpu.endian",  sprops->cpu_endian);
       
   262 
       
   263 
   162 
   264 #ifdef MACOSX
   163 #ifdef MACOSX
       
   164     PUTPROP(propArray, _java_awt_headless_NDX, sprops->awt_headless);
       
   165 
   265     /* Proxy setting properties */
   166     /* Proxy setting properties */
   266     if (sprops->httpProxyEnabled) {
   167     if (sprops->httpProxyEnabled) {
   267         PUTPROP(props, "http.proxyHost", sprops->httpHost);
   168         PUTPROP(propArray, _http_proxyHost_NDX, sprops->httpHost);
   268         PUTPROP(props, "http.proxyPort", sprops->httpPort);
   169         PUTPROP(propArray, _http_proxyPort_NDX, sprops->httpPort);
   269     }
   170     }
   270 
   171 
   271     if (sprops->httpsProxyEnabled) {
   172     if (sprops->httpsProxyEnabled) {
   272         PUTPROP(props, "https.proxyHost", sprops->httpsHost);
   173         PUTPROP(propArray, _https_proxyHost_NDX, sprops->httpsHost);
   273         PUTPROP(props, "https.proxyPort", sprops->httpsPort);
   174         PUTPROP(propArray, _https_proxyPort_NDX, sprops->httpsPort);
   274     }
   175     }
   275 
   176 
   276     if (sprops->ftpProxyEnabled) {
   177     if (sprops->ftpProxyEnabled) {
   277         PUTPROP(props, "ftp.proxyHost", sprops->ftpHost);
   178         PUTPROP(propArray, _ftp_proxyHost_NDX, sprops->ftpHost);
   278         PUTPROP(props, "ftp.proxyPort", sprops->ftpPort);
   179         PUTPROP(propArray, _ftp_proxyPort_NDX, sprops->ftpPort);
   279     }
   180     }
   280 
   181 
   281     if (sprops->socksProxyEnabled) {
   182     if (sprops->socksProxyEnabled) {
   282         PUTPROP(props, "socksProxyHost", sprops->socksHost);
   183         PUTPROP(propArray, _socksProxyHost_NDX, sprops->socksHost);
   283         PUTPROP(props, "socksProxyPort", sprops->socksPort);
   184         PUTPROP(propArray, _socksProxyPort_NDX, sprops->socksPort);
   284     }
   185     }
   285 
   186 
   286     if (sprops->gopherProxyEnabled) {
   187     if (sprops->gopherProxyEnabled) {
   287         // The gopher client is different in that it expects an 'is this set?' flag that the others don't.
   188         // The gopher client is different in that it expects an 'is this set?' flag that the others don't.
   288         PUTPROP(props, "gopherProxySet", "true");
   189         PUTPROP(propArray, _gopherProxySet_NDX, "true");
   289         PUTPROP(props, "gopherProxyHost", sprops->gopherHost);
   190         PUTPROP(propArray, _gopherProxyHost_NDX, sprops->gopherHost);
   290         PUTPROP(props, "gopherProxyPort", sprops->gopherPort);
   191         PUTPROP(propArray, _gopherProxyPort_NDX, sprops->gopherPort);
   291     } else {
   192     } else {
   292         PUTPROP(props, "gopherProxySet", "false");
   193         PUTPROP(propArray, _gopherProxySet_NDX, "false");
   293     }
   194     }
   294 
   195 
   295     // Mac OS X only has a single proxy exception list which applies
   196     // Mac OS X only has a single proxy exception list which applies
   296     // to all protocols
   197     // to all protocols
   297     if (sprops->exceptionList) {
   198     if (sprops->exceptionList) {
   298         PUTPROP(props, "http.nonProxyHosts", sprops->exceptionList);
   199         PUTPROP(propArray, _http_nonProxyHosts_NDX, sprops->exceptionList);
   299         PUTPROP(props, "ftp.nonProxyHosts", sprops->exceptionList);
   200         PUTPROP(propArray, _ftp_nonProxyHosts_NDX, sprops->exceptionList);
   300         PUTPROP(props, "socksNonProxyHosts", sprops->exceptionList);
   201         PUTPROP(propArray, _socksNonProxyHosts_NDX, sprops->exceptionList);
   301     }
   202     }
   302 #endif
   203 #endif
   303 
   204 
   304     /* !!! DO NOT call PUTPROP_ForPlatformNString before this line !!!
   205     /* data model */
   305      * !!! The platform native encoding for strings has not been set up yet !!!
   206     if (sizeof(sprops) == 4) {
   306      */
   207         sprops->data_model = "32";
   307     InitializeEncoding(env, sprops->sun_jnu_encoding);
   208     } else if (sizeof(sprops) == 8) {
       
   209         sprops->data_model = "64";
       
   210     } else {
       
   211         sprops->data_model = "unknown";
       
   212     }
       
   213     PUTPROP(propArray, _sun_arch_data_model_NDX, sprops->data_model);
       
   214 
       
   215     /* patch level */
       
   216     PUTPROP(propArray, _sun_os_patch_level_NDX, sprops->patch_level);
   308 
   217 
   309     /* Printing properties */
   218     /* Printing properties */
   310     /* Note: java.awt.printerjob is an implementation private property which
   219     /* Note: java.awt.printerjob is an implementation private property which
   311      * just happens to have a java.* name because it is referenced in
   220      * just happens to have a java.* name because it is referenced in
   312      * a java.awt class. It is the mechanism by which the implementation
   221      * a java.awt class. It is the mechanism by which the implementation
   315      * a way of replacing the implementation class, and in any case
   224      * a way of replacing the implementation class, and in any case
   316      * the mechanism by which the class is loaded is constrained to only
   225      * the mechanism by which the class is loaded is constrained to only
   317      * find and load classes that are part of the JRE.
   226      * find and load classes that are part of the JRE.
   318      * This property may be removed if that mechanism is redesigned
   227      * This property may be removed if that mechanism is redesigned
   319      */
   228      */
   320     PUTPROP(props, "java.awt.printerjob", sprops->printerJob);
   229     PUTPROP(propArray, _java_awt_printerjob_NDX, sprops->printerJob);
   321 
   230 
   322     /* data model */
   231     PUTPROP(propArray, _awt_toolkit_NDX, sprops->awt_toolkit);
   323     if (sizeof(sprops) == 4) {
       
   324         sprops->data_model = "32";
       
   325     } else if (sizeof(sprops) == 8) {
       
   326         sprops->data_model = "64";
       
   327     } else {
       
   328         sprops->data_model = "unknown";
       
   329     }
       
   330     PUTPROP(props, "sun.arch.data.model",  \
       
   331                     sprops->data_model);
       
   332 
       
   333     /* patch level */
       
   334     if (sprops->patch_level != NULL) {
       
   335         PUTPROP(props, "sun.os.patch.level",  \
       
   336                     sprops->patch_level);
       
   337     }
       
   338 
   232 
   339     /* Java2D properties */
   233     /* Java2D properties */
   340     /* Note: java.awt.graphicsenv is an implementation private property which
   234     /* Note: java.awt.graphicsenv is an implementation private property which
   341      * just happens to have a java.* name because it is referenced in
   235      * just happens to have a java.* name because it is referenced in
   342      * a java.awt class. It is the mechanism by which the implementation
   236      * a java.awt class. It is the mechanism by which the implementation
   345      * a way of replacing the implementation class, and in any case
   239      * a way of replacing the implementation class, and in any case
   346      * the mechanism by which the class is loaded is constrained to only
   240      * the mechanism by which the class is loaded is constrained to only
   347      * find and load classes that are part of the JRE.
   241      * find and load classes that are part of the JRE.
   348      * This property may be removed if that mechanism is redesigned
   242      * This property may be removed if that mechanism is redesigned
   349      */
   243      */
   350     PUTPROP(props, "java.awt.graphicsenv", sprops->graphics_env);
   244     PUTPROP(propArray, _java_awt_graphicsenv_NDX, sprops->graphics_env);
   351     if (sprops->font_dir != NULL) {
   245     PUTPROP_PlatformString(propArray, _sun_java2d_fontpath_NDX, sprops->font_dir);
   352         PUTPROP_ForPlatformNString(props,
   246 
   353                                    "sun.java2d.fontpath", sprops->font_dir);
   247     /*
   354     }
   248      * The sun.desktop property is currently only set for Gnome and Windows desktops.
   355 
   249      */
   356     PUTPROP_ForPlatformNString(props, "java.io.tmpdir", sprops->tmp_dir);
   250     PUTPROP(propArray, _sun_desktop_NDX, sprops->desktop);
   357 
   251 
   358     PUTPROP_ForPlatformNString(props, "user.name", sprops->user_name);
   252     PUTPROP_PlatformString(propArray, _java_io_tmpdir_NDX, sprops->tmp_dir);
   359     PUTPROP_ForPlatformNString(props, "user.home", sprops->user_home);
   253 
   360     PUTPROP_ForPlatformNString(props, "user.dir", sprops->user_dir);
   254     PUTPROP_PlatformString(propArray, _user_name_NDX, sprops->user_name);
   361 
   255     PUTPROP_PlatformString(propArray, _user_home_NDX, sprops->user_home);
   362     /* This is a sun. property as it is currently only set for Gnome and
   256     PUTPROP_PlatformString(propArray, _user_dir_NDX, sprops->user_dir);
   363      * Windows desktops.
   257 
   364      */
   258    /*
   365     if (sprops->desktop != NULL) {
   259     * Set i18n related property fields from platform.
   366         PUTPROP(props, "sun.desktop", sprops->desktop);
   260     */
   367     }
   261    PUTPROP(propArray, _display_language_NDX, sprops->display_language);
   368 
   262    PUTPROP(propArray, _display_script_NDX, sprops->display_script);
   369     ret = JVM_InitProperties(env, props);
   263    PUTPROP(propArray, _display_country_NDX, sprops->display_country);
   370 
   264    PUTPROP(propArray, _display_variant_NDX, sprops->display_variant);
   371     /* reconstruct i18n related properties */
   265 
   372     fillI18nProps(env, props, "user.language", sprops->display_language,
   266    PUTPROP(propArray, _format_language_NDX, sprops->format_language);
   373         sprops->format_language, putID, getPropID);
   267    PUTPROP(propArray, _format_script_NDX, sprops->format_script);
   374     fillI18nProps(env, props, "user.script",
   268    PUTPROP(propArray, _format_country_NDX, sprops->format_country);
   375         sprops->display_script, sprops->format_script, putID, getPropID);
   269    PUTPROP(propArray, _format_variant_NDX, sprops->format_variant);
   376     fillI18nProps(env, props, "user.country",
   270 
   377         sprops->display_country, sprops->format_country, putID, getPropID);
   271    return propArray;
   378     fillI18nProps(env, props, "user.variant",
   272 }
   379         sprops->display_variant, sprops->format_variant, putID, getPropID);
   273 
   380     GETPROP(props, "file.encoding", jVMVal);
   274 /*
   381     if (jVMVal == NULL) {
   275  * Gather the VM and command line properties and return as a String[].
   382 #ifdef MACOSX
   276  * The array indices are alternating key/value pairs
   383         /*
   277  * supplied by the VM including those defined on the command line
   384          * Since sun_jnu_encoding is now hard-coded to UTF-8 on Mac, we don't
   278  * using -Dkey=value that may override the platform defined value.
   385          * want to use it to overwrite file.encoding
   279  *
   386          */
   280  * Note: The platform encoding must have been set.
   387         PUTPROP(props, "file.encoding", sprops->encoding);
   281  *
   388 #else
   282  * Class:     jdk_internal_util_SystemProps_Raw
   389         PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding);
   283  * Method:    vmProperties
   390 #endif
   284  * Signature: ()[Ljava/lang/String;
   391     } else {
   285  */
   392         (*env)->DeleteLocalRef(env, jVMVal);
   286 JNIEXPORT jobjectArray JNICALL
   393     }
   287 Java_jdk_internal_util_SystemProps_00024Raw_vmProperties(JNIEnv *env, jclass cla)
   394 
   288 {
   395     // Platform defined encoding properties override any on the command line
   289     jobjectArray cmdProps = JVM_GetProperties(env);
   396     PUTPROP(props, "sun.jnu.encoding", sprops->sun_jnu_encoding);
   290     return cmdProps;
   397 
       
   398     return ret;
       
   399 }
   291 }
   400 
   292 
   401 /*
   293 /*
   402  * The following three functions implement setter methods for
   294  * The following three functions implement setter methods for
   403  * java.lang.System.{in, out, err}. They are natively implemented
   295  * java.lang.System.{in, out, err}. They are natively implemented