src/java.base/share/native/libjava/System.c
author rriggs
Tue, 13 Mar 2018 12:46:01 -0400
changeset 49213 b43edd41622d
parent 49121 10f447530d32
child 49292 dde7eaaa3ddc
permissions -rw-r--r--
8199470: Remove unused property file.encoding.pkg Reviewed-by: bpb, sherman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
48081
89829dd3cc54 8188870: Bump classfile version number to 54
psandoz
parents: 47216
diff changeset
     2
 * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "jni.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "jni_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "jvm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "java_props.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "java_lang_System.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#define OBJ "Ljava/lang/Object;"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/* Only register the performance-critical methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
static JNINativeMethod methods[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    {"currentTimeMillis", "()J",              (void *)&JVM_CurrentTimeMillis},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    {"nanoTime",          "()J",              (void *)&JVM_NanoTime},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    {"arraycopy",     "(" OBJ "I" OBJ "II)V", (void *)&JVM_ArrayCopy},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#undef OBJ
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
Java_java_lang_System_registerNatives(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    (*env)->RegisterNatives(env, cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
                            methods, sizeof(methods)/sizeof(methods[0]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    return JVM_IHashCode(env, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
22641
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    59
#define PUTPROP(props, key, val)                                     \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    60
    if (1) {                                                         \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    61
        jstring jkey, jval;                                          \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    62
        jobject r;                                                   \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    63
        jkey = (*env)->NewStringUTF(env, key);                       \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    64
        if (jkey == NULL) return NULL;                               \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    65
        jval = (*env)->NewStringUTF(env, val);                       \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    66
        if (jval == NULL) return NULL;                               \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    67
        r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    68
        if ((*env)->ExceptionOccurred(env)) return NULL;             \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    69
        (*env)->DeleteLocalRef(env, jkey);                           \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    70
        (*env)->DeleteLocalRef(env, jval);                           \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    71
        (*env)->DeleteLocalRef(env, r);                              \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    } else ((void) 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
    74
/*  "key" is a char type string with only ASCII character in it.
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
    75
    "val" is a nchar (typedefed in java_props.h) type string  */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
    76
22641
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    77
#define PUTPROP_ForPlatformNString(props, key, val)                  \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    78
    if (1) {                                                         \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    79
        jstring jkey, jval;                                          \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    80
        jobject r;                                                   \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    81
        jkey = (*env)->NewStringUTF(env, key);                       \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    82
        if (jkey == NULL) return NULL;                               \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    83
        jval = GetStringPlatform(env, val);                          \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    84
        if (jval == NULL) return NULL;                               \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    85
        r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    86
        if ((*env)->ExceptionOccurred(env)) return NULL;             \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    87
        (*env)->DeleteLocalRef(env, jkey);                           \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    88
        (*env)->DeleteLocalRef(env, jval);                           \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    89
        (*env)->DeleteLocalRef(env, r);                              \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    } else ((void) 0)
22641
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    91
#define REMOVEPROP(props, key)                                    \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    92
    if (1) {                                                      \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    93
        jstring jkey;                                             \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    94
        jobject r;                                                \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    95
        jkey = JNU_NewStringPlatform(env, key);                   \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    96
        if (jkey == NULL) return NULL;                            \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    97
        r = (*env)->CallObjectMethod(env, props, removeID, jkey); \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    98
        if ((*env)->ExceptionOccurred(env)) return NULL;          \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
    99
        (*env)->DeleteLocalRef(env, jkey);                        \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   100
        (*env)->DeleteLocalRef(env, r);                           \
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   101
    } else ((void) 0)
22641
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   102
#define GETPROP(props, key, jret)                                     \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   103
    if (1) {                                                          \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   104
        jstring jkey = JNU_NewStringPlatform(env, key);               \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   105
        if (jkey == NULL) return NULL;                                \
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   106
        jret = (*env)->CallObjectMethod(env, props, getPropID, jkey); \
22641
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   107
        if ((*env)->ExceptionOccurred(env)) return NULL;              \
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   108
        (*env)->DeleteLocalRef(env, jkey);                            \
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   109
    } else ((void) 0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
48598
c7eea4b541d1 8189761: COMPANY_NAME, IMPLEMENTOR, BUNDLE_VENDOR, VENDOR, but no configure flag
simonis
parents: 48393
diff changeset
   111
/* Third party may overwrite these values. */
c7eea4b541d1 8189761: COMPANY_NAME, IMPLEMENTOR, BUNDLE_VENDOR, VENDOR, but no configure flag
simonis
parents: 48393
diff changeset
   112
#ifndef VENDOR
6676
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   113
#define VENDOR "Oracle Corporation"
48598
c7eea4b541d1 8189761: COMPANY_NAME, IMPLEMENTOR, BUNDLE_VENDOR, VENDOR, but no configure flag
simonis
parents: 48393
diff changeset
   114
#endif
c7eea4b541d1 8189761: COMPANY_NAME, IMPLEMENTOR, BUNDLE_VENDOR, VENDOR, but no configure flag
simonis
parents: 48393
diff changeset
   115
#ifndef VENDOR_URL
6676
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   116
#define VENDOR_URL "http://java.oracle.com/"
48598
c7eea4b541d1 8189761: COMPANY_NAME, IMPLEMENTOR, BUNDLE_VENDOR, VENDOR, but no configure flag
simonis
parents: 48393
diff changeset
   117
#endif
c7eea4b541d1 8189761: COMPANY_NAME, IMPLEMENTOR, BUNDLE_VENDOR, VENDOR, but no configure flag
simonis
parents: 48393
diff changeset
   118
#ifndef VENDOR_URL_BUG
30819
45d6fd3af6ac 8081359: Update bug reporting URL
darcy
parents: 27565
diff changeset
   119
#define VENDOR_URL_BUG "http://bugreport.java.com/bugreport/"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
6676
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   122
#ifdef JAVA_SPECIFICATION_VENDOR /* Third party may NOT overwrite this. */
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   123
  #error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   124
#else
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   125
  #define JAVA_SPECIFICATION_VENDOR "Oracle Corporation"
6850
56966b0a6a0d 6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents: 6683
diff changeset
   126
#endif
6683
lana
parents: 6676 6489
diff changeset
   127
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   128
jobject fillI18nProps(JNIEnv *env, jobject props, char *baseKey,
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   129
                      char *platformDispVal, char *platformFmtVal,
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   130
                      jmethodID putID, jmethodID getPropID) {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   131
    jstring jVMBaseVal = NULL;
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   132
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   133
    GETPROP(props, baseKey, jVMBaseVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   134
    if (jVMBaseVal) {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   135
        // user specified the base property.  there's nothing to do here.
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   136
        (*env)->DeleteLocalRef(env, jVMBaseVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   137
    } else {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   138
        char buf[64];
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   139
        jstring jVMVal = NULL;
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   140
        const char *baseVal = "";
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   141
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   142
        /* user.xxx base property */
48928
cc30928a834e 8198385: Remove property sun.locale.formatasdefault
naoto
parents: 48608
diff changeset
   143
        if (platformDispVal) {
cc30928a834e 8198385: Remove property sun.locale.formatasdefault
naoto
parents: 48608
diff changeset
   144
            PUTPROP(props, baseKey, platformDispVal);
cc30928a834e 8198385: Remove property sun.locale.formatasdefault
naoto
parents: 48608
diff changeset
   145
            baseVal = platformDispVal;
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   146
        }
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   147
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   148
        /* user.xxx.display property */
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   149
        jio_snprintf(buf, sizeof(buf), "%s.display", baseKey);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   150
        GETPROP(props, buf, jVMVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   151
        if (jVMVal == NULL) {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   152
            if (platformDispVal && (strcmp(baseVal, platformDispVal) != 0)) {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   153
                PUTPROP(props, buf, platformDispVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   154
            }
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   155
        } else {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   156
            (*env)->DeleteLocalRef(env, jVMVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   157
        }
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   158
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   159
        /* user.xxx.format property */
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   160
        jio_snprintf(buf, sizeof(buf), "%s.format", baseKey);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   161
        GETPROP(props, buf, jVMVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   162
        if (jVMVal == NULL) {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   163
            if (platformFmtVal && (strcmp(baseVal, platformFmtVal) != 0)) {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   164
                PUTPROP(props, buf, platformFmtVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   165
            }
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   166
        } else {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   167
            (*env)->DeleteLocalRef(env, jVMVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   168
        }
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   169
    }
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   170
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   171
    return NULL;
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   172
}
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   173
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    char buf[128];
22641
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   178
    java_props_t *sprops;
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   179
    jmethodID putID, removeID, getPropID;
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   180
    jobject ret = NULL;
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   181
    jstring jVMVal = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
48393
993b004ab38f 8190984: tools/launcher/TestXcheckJNIWarnings.java WARNING was found in the output
bchristi
parents: 48081
diff changeset
   183
    if ((*env)->EnsureLocalCapacity(env, 50) < 0) {
993b004ab38f 8190984: tools/launcher/TestXcheckJNIWarnings.java WARNING was found in the output
bchristi
parents: 48081
diff changeset
   184
        return NULL;
993b004ab38f 8190984: tools/launcher/TestXcheckJNIWarnings.java WARNING was found in the output
bchristi
parents: 48081
diff changeset
   185
    }
22641
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   186
    sprops = GetJavaProperties(env);
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   187
    CHECK_NULL_RETURN(sprops, NULL);
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   188
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   189
    putID = (*env)->GetMethodID(env,
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   190
                                (*env)->GetObjectClass(env, props),
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   191
                                "put",
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   192
            "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   193
    CHECK_NULL_RETURN(putID, NULL);
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   194
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   195
    removeID = (*env)->GetMethodID(env,
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   196
                                   (*env)->GetObjectClass(env, props),
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   197
                                   "remove",
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   198
            "(Ljava/lang/Object;)Ljava/lang/Object;");
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   199
    CHECK_NULL_RETURN(removeID, NULL);
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   200
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   201
    getPropID = (*env)->GetMethodID(env,
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   202
                                    (*env)->GetObjectClass(env, props),
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   203
                                    "getProperty",
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   204
            "(Ljava/lang/String;)Ljava/lang/String;");
e47f8892133e 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents: 21130
diff changeset
   205
    CHECK_NULL_RETURN(getPropID, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    PUTPROP(props, "java.specification.version",
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 30819
diff changeset
   208
            VERSION_SPECIFICATION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    PUTPROP(props, "java.specification.name",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            "Java Platform API Specification");
6676
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   211
    PUTPROP(props, "java.specification.vendor",
c8629a8bbd7d 6946527: rebranding system properties per Oracle Requirements (vendor)
ohair
parents: 5506
diff changeset
   212
            JAVA_SPECIFICATION_VENDOR);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 30819
diff changeset
   214
    PUTPROP(props, "java.version", VERSION_SHORT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    PUTPROP(props, "java.vendor", VENDOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    PUTPROP(props, "java.vendor.url", VENDOR_URL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    PUTPROP(props, "java.vendor.url.bug", VENDOR_URL_BUG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
48355
4944950606ef 8191913: Bump classfile version number to 55
psandoz
parents: 48081
diff changeset
   219
    jio_snprintf(buf, sizeof(buf), "%d.%d", JVM_CLASSFILE_MAJOR_VERSION,
4944950606ef 8191913: Bump classfile version number to 55
psandoz
parents: 48081
diff changeset
   220
                                            JVM_CLASSFILE_MINOR_VERSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    PUTPROP(props, "java.class.version", buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    if (sprops->awt_toolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        PUTPROP(props, "awt.toolkit", sprops->awt_toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
21130
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 16041
diff changeset
   226
#ifdef MACOSX
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 16041
diff changeset
   227
    if (sprops->awt_headless) {
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 16041
diff changeset
   228
        PUTPROP(props, "java.awt.headless", sprops->awt_headless);
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 16041
diff changeset
   229
    }
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 16041
diff changeset
   230
#endif
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /* os properties */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    PUTPROP(props, "os.name", sprops->os_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    PUTPROP(props, "os.version", sprops->os_version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    PUTPROP(props, "os.arch", sprops->os_arch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
16041
b9d38accf302 8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents: 15004
diff changeset
   237
#ifdef JDK_ARCH_ABI_PROP_NAME
b9d38accf302 8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents: 15004
diff changeset
   238
    PUTPROP(props, "sun.arch.abi", sprops->sun_arch_abi);
b9d38accf302 8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents: 15004
diff changeset
   239
#endif
b9d38accf302 8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents: 15004
diff changeset
   240
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /* file system properties */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    PUTPROP(props, "file.separator", sprops->file_separator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    PUTPROP(props, "path.separator", sprops->path_separator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    PUTPROP(props, "line.separator", sprops->line_separator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *  user.language
7017
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   248
     *  user.script, user.country, user.variant (if user's environment specifies them)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *  file.encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    PUTPROP(props, "user.language", sprops->language);
7017
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   252
    if (sprops->script) {
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   253
        PUTPROP(props, "user.script", sprops->script);
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   254
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    if (sprops->country) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        PUTPROP(props, "user.country", sprops->country);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    if (sprops->variant) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        PUTPROP(props, "user.variant", sprops->variant);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    PUTPROP(props, "file.encoding", sprops->encoding);
11906
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 9036
diff changeset
   262
    if (sprops->sun_stdout_encoding != NULL) {
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 9036
diff changeset
   263
        PUTPROP(props, "sun.stdout.encoding", sprops->sun_stdout_encoding);
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 9036
diff changeset
   264
    }
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 9036
diff changeset
   265
    if (sprops->sun_stderr_encoding != NULL) {
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 9036
diff changeset
   266
        PUTPROP(props, "sun.stderr.encoding", sprops->sun_stderr_encoding);
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 9036
diff changeset
   267
    }
dc984e35d8a6 4153167: separate between ANSI and OEM code pages on Windows
sherman
parents: 9036
diff changeset
   268
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    /* unicode_encoding specifies the default endianness */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    PUTPROP(props, "sun.cpu.isalist",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            (sprops->cpu_isalist ? sprops->cpu_isalist : ""));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    PUTPROP(props, "sun.cpu.endian",  sprops->cpu_endian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   275
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   276
#ifdef MACOSX
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   277
    /* Proxy setting properties */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   278
    if (sprops->httpProxyEnabled) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   279
        PUTPROP(props, "http.proxyHost", sprops->httpHost);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   280
        PUTPROP(props, "http.proxyPort", sprops->httpPort);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   281
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   282
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   283
    if (sprops->httpsProxyEnabled) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   284
        PUTPROP(props, "https.proxyHost", sprops->httpsHost);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   285
        PUTPROP(props, "https.proxyPort", sprops->httpsPort);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   286
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   287
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   288
    if (sprops->ftpProxyEnabled) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   289
        PUTPROP(props, "ftp.proxyHost", sprops->ftpHost);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   290
        PUTPROP(props, "ftp.proxyPort", sprops->ftpPort);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   291
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   292
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   293
    if (sprops->socksProxyEnabled) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   294
        PUTPROP(props, "socksProxyHost", sprops->socksHost);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   295
        PUTPROP(props, "socksProxyPort", sprops->socksPort);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   296
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   297
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   298
    if (sprops->gopherProxyEnabled) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   299
        // The gopher client is different in that it expects an 'is this set?' flag that the others don't.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   300
        PUTPROP(props, "gopherProxySet", "true");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   301
        PUTPROP(props, "gopherProxyHost", sprops->gopherHost);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   302
        PUTPROP(props, "gopherProxyPort", sprops->gopherPort);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   303
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   304
        PUTPROP(props, "gopherProxySet", "false");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   305
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   306
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   307
    // 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
   308
    // to all protocols
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   309
    if (sprops->exceptionList) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   310
        PUTPROP(props, "http.nonProxyHosts", sprops->exceptionList);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   311
        PUTPROP(props, "ftp.nonProxyHosts", sprops->exceptionList);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   312
        PUTPROP(props, "socksNonProxyHosts", sprops->exceptionList);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   313
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   314
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11906
diff changeset
   315
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   316
    /* !!! DO NOT call PUTPROP_ForPlatformNString before this line !!!
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * !!! I18n properties have not been set up yet !!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     */
49121
10f447530d32 8198697: Simplify initialization of platform encoding
rriggs
parents: 48928
diff changeset
   319
    InitializeEncoding(env, sprops->sun_jnu_encoding);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /* Printing properties */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /* Note: java.awt.printerjob is an implementation private property which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * 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
   324
     * a java.awt class. It is the mechanism by which the implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * finds the appropriate class in the JRE for the platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * It is explicitly not designed to be overridden by clients as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * a way of replacing the implementation class, and in any case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * the mechanism by which the class is loaded is constrained to only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * find and load classes that are part of the JRE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * This property may be removed if that mechanism is redesigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    PUTPROP(props, "java.awt.printerjob", sprops->printerJob);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /* data model */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    if (sizeof(sprops) == 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        sprops->data_model = "32";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    } else if (sizeof(sprops) == 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        sprops->data_model = "64";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        sprops->data_model = "unknown";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    PUTPROP(props, "sun.arch.data.model",  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                    sprops->data_model);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    /* patch level */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    PUTPROP(props, "sun.os.patch.level",  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                    sprops->patch_level);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /* Java2D properties */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /* Note: java.awt.graphicsenv is an implementation private property which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * 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
   352
     * a java.awt class. It is the mechanism by which the implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * finds the appropriate class in the JRE for the platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * It is explicitly not designed to be overridden by clients as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * a way of replacing the implementation class, and in any case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * the mechanism by which the class is loaded is constrained to only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * find and load classes that are part of the JRE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * This property may be removed if that mechanism is redesigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    PUTPROP(props, "java.awt.graphicsenv", sprops->graphics_env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    if (sprops->font_dir != NULL) {
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   362
        PUTPROP_ForPlatformNString(props,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                                   "sun.java2d.fontpath", sprops->font_dir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   366
    PUTPROP_ForPlatformNString(props, "java.io.tmpdir", sprops->tmp_dir);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   368
    PUTPROP_ForPlatformNString(props, "user.name", sprops->user_name);
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   369
    PUTPROP_ForPlatformNString(props, "user.home", sprops->user_home);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    PUTPROP(props, "user.timezone", sprops->timezone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   373
    PUTPROP_ForPlatformNString(props, "user.dir", sprops->user_dir);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    /* This is a sun. property as it is currently only set for Gnome and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * Windows desktops.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    if (sprops->desktop != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        PUTPROP(props, "sun.desktop", sprops->desktop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   382
    /*
7017
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   383
     * unset "user.language", "user.script", "user.country", and "user.variant"
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   384
     * in order to tell whether the command line option "-DXXXX=YYYY" is
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   385
     * specified or not.  They will be reset in fillI18nProps() below.
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   386
     */
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   387
    REMOVEPROP(props, "user.language");
7017
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   388
    REMOVEPROP(props, "user.script");
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   389
    REMOVEPROP(props, "user.country");
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   390
    REMOVEPROP(props, "user.variant");
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   391
    REMOVEPROP(props, "file.encoding");
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   392
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   393
    ret = JVM_InitProperties(env, props);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   394
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   395
    /* reconstruct i18n related properties */
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   396
    fillI18nProps(env, props, "user.language", sprops->display_language,
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   397
        sprops->format_language, putID, getPropID);
7017
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   398
    fillI18nProps(env, props, "user.script",
f3bfa15db005 6989111: Incorrect default locale for New Zealand
naoto
parents: 6683
diff changeset
   399
        sprops->display_script, sprops->format_script, putID, getPropID);
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   400
    fillI18nProps(env, props, "user.country",
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   401
        sprops->display_country, sprops->format_country, putID, getPropID);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   402
    fillI18nProps(env, props, "user.variant",
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   403
        sprops->display_variant, sprops->format_variant, putID, getPropID);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   404
    GETPROP(props, "file.encoding", jVMVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   405
    if (jVMVal == NULL) {
15004
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   406
#ifdef MACOSX
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   407
        /*
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   408
         * Since sun_jnu_encoding is now hard-coded to UTF-8 on Mac, we don't
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   409
         * want to use it to overwrite file.encoding
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   410
         */
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   411
        PUTPROP(props, "file.encoding", sprops->encoding);
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   412
#else
48928
cc30928a834e 8198385: Remove property sun.locale.formatasdefault
naoto
parents: 48608
diff changeset
   413
        PUTPROP(props, "file.encoding", sprops->sun_jnu_encoding);
15004
cf5d2d5094cc 8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents: 14406
diff changeset
   414
#endif
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   415
    } else {
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   416
        (*env)->DeleteLocalRef(env, jVMVal);
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   417
    }
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   418
49121
10f447530d32 8198697: Simplify initialization of platform encoding
rriggs
parents: 48928
diff changeset
   419
    // Platform defined encoding properties override any on the command line
10f447530d32 8198697: Simplify initialization of platform encoding
rriggs
parents: 48928
diff changeset
   420
    PUTPROP(props, "sun.jnu.encoding", sprops->sun_jnu_encoding);
10f447530d32 8198697: Simplify initialization of platform encoding
rriggs
parents: 48928
diff changeset
   421
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   422
    return ret;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
 * The following three functions implement setter methods for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
 * java.lang.System.{in, out, err}. They are natively implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
 * because they violate the semantics of the language (i.e. set final
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
 * variable).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    jfieldID fid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        (*env)->GetStaticFieldID(env,cla,"in","Ljava/io/InputStream;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    if (fid == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    (*env)->SetStaticObjectField(env,cla,fid,stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
Java_java_lang_System_setOut0(JNIEnv *env, jclass cla, jobject stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    jfieldID fid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        (*env)->GetStaticFieldID(env,cla,"out","Ljava/io/PrintStream;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    if (fid == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    (*env)->SetStaticObjectField(env,cla,fid,stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
Java_java_lang_System_setErr0(JNIEnv *env, jclass cla, jobject stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    jfieldID fid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        (*env)->GetStaticFieldID(env,cla,"err","Ljava/io/PrintStream;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    if (fid == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    (*env)->SetStaticObjectField(env,cla,fid,stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
static void cpchars(jchar *dst, char *src, int n)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        dst[i] = src[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
Java_java_lang_System_mapLibraryName(JNIEnv *env, jclass ign, jstring libname)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    int len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    int prefix_len = (int) strlen(JNI_LIB_PREFIX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    int suffix_len = (int) strlen(JNI_LIB_SUFFIX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    jchar chars[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    if (libname == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        JNU_ThrowNullPointerException(env, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    len = (*env)->GetStringLength(env, libname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    if (len > 240) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        JNU_ThrowIllegalArgumentException(env, "name too long");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    cpchars(chars, JNI_LIB_PREFIX, prefix_len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    (*env)->GetStringRegion(env, libname, 0, len, chars + prefix_len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    len += prefix_len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    cpchars(chars + len, JNI_LIB_SUFFIX, suffix_len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    len += suffix_len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    return (*env)->NewString(env, chars, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
}