/* * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* VENDOR, VENDOR_URL, VENDOR_URL_BUG are set in VersionProps.java.template. */
/* * Store the UTF-8 string encoding of the value in the array * at the index if the value is non-null. Store nothing if the value is null. * On any error, return from Java_jdk_internal_util_SystemProps_00024Raw_platformProperties.
*/ #define PUTPROP(array, prop_index, val) \ if (val != NULL) { \
jstring jval = (*env)->NewStringUTF(env, val); \ if (jval == NULL) \ return NULL; \
(*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \ if ((*env)->ExceptionOccurred(env)) \ return NULL; \
(*env)->DeleteLocalRef(env, jval); \
}
/* * Store the Platform string encoding of the value in the array * at the index if the value is non-null. Store nothing if the value is null. * On any error, return from Java_jdk_internal_util_SystemProps_00024Raw_platformProperties.
*/ #define PUTPROP_PlatformString(array, prop_index, val) \ if (val != NULL) { \
jstring jval = GetStringPlatform(env, val); \ if (jval == NULL) \ return NULL; \
(*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \ if ((*env)->ExceptionOccurred(env)) \ return NULL; \
(*env)->DeleteLocalRef(env, jval); \
}
/* * Gather the system properties and return as a String[]. * The first FIXED_LENGTH entries are the platform defined property values, no names. * The remaining array indices are alternating key/value pairs * supplied by the VM including those defined on the command line * using -Dkey=value that may override the platform defined value. * The caller is responsible for replacing platform provided values as needed. * * Class: jdk_internal_util_SystemProps_Raw * Method: platformProperties * Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL
Java_jdk_internal_util_SystemProps_00024Raw_platformProperties(JNIEnv *env, jclass cla)
{
java_props_t *sprops;
jobject propArray = NULL;
jclass classString; int nstrings = jdk_internal_util_SystemProps_Raw_FIXED_LENGTH;
// Get the platform specific values
sprops = GetJavaProperties(env);
CHECK_NULL_RETURN(sprops, NULL);
/* * !!! DO NOT call PUTPROP_PlatformString (NewStringPlatform) before this line !!!
*/
InitializeEncoding(env, sprops->sun_jnu_encoding);
// Ensure capacity for the array and for a string for each fixed length element if ((*env)->EnsureLocalCapacity(env, nstrings + 2) < 0) { return NULL;
}
// Allocate an array of String for all the well known props
classString = JNU_ClassString(env);
CHECK_NULL_RETURN(classString, NULL);
#ifdef MACOSX /* * Since sun_jnu_encoding is now hard-coded to UTF-8 on Mac, we don't * want to use it to overwrite file.encoding
*/
PUTPROP(propArray, _file_encoding_NDX, sprops->encoding); #else
PUTPROP(propArray, _file_encoding_NDX, sprops->sun_jnu_encoding); #endif
PUTPROP(propArray, _sun_jnu_encoding_NDX, sprops->sun_jnu_encoding);
/* * file encoding for stdout and stderr
*/
PUTPROP(propArray, _stdout_encoding_NDX, sprops->stdout_encoding);
PUTPROP(propArray, _stderr_encoding_NDX, sprops->stderr_encoding);
if (sprops->httpsProxyEnabled) {
PUTPROP(propArray, _https_proxyHost_NDX, sprops->httpsHost);
PUTPROP(propArray, _https_proxyPort_NDX, sprops->httpsPort);
}
if (sprops->ftpProxyEnabled) {
PUTPROP(propArray, _ftp_proxyHost_NDX, sprops->ftpHost);
PUTPROP(propArray, _ftp_proxyPort_NDX, sprops->ftpPort);
}
if (sprops->socksProxyEnabled) {
PUTPROP(propArray, _socksProxyHost_NDX, sprops->socksHost);
PUTPROP(propArray, _socksProxyPort_NDX, sprops->socksPort);
}
// Mac OS X only has a single proxy exception list which applies // to all protocols if (sprops->exceptionList) {
PUTPROP(propArray, _http_nonProxyHosts_NDX, sprops->exceptionList);
PUTPROP(propArray, _ftp_nonProxyHosts_NDX, sprops->exceptionList);
PUTPROP(propArray, _socksNonProxyHosts_NDX, sprops->exceptionList);
} #endif
/* * Gather the VM and command line properties and return as a String[]. * The array indices are alternating key/value pairs * supplied by the VM including those defined on the command line * using -Dkey=value that may override the platform defined value. * * Note: The platform encoding must have been set. * * Class: jdk_internal_util_SystemProps_Raw * Method: vmProperties * Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL
Java_jdk_internal_util_SystemProps_00024Raw_vmProperties(JNIEnv *env, jclass cla)
{
jobjectArray cmdProps = JVM_GetProperties(env); return cmdProps;
}
/* * The following three functions implement setter methods for * java.lang.System.{in, out, err}. They are natively implemented * because they violate the semantics of the language (i.e. set final * variable).
*/
JNIEXPORT void JNICALL
Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream)
{
jfieldID fid =
(*env)->GetStaticFieldID(env,cla,"in","Ljava/io/InputStream;"); if (fid == 0) return;
(*env)->SetStaticObjectField(env,cla,fid,stream);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.