fixed Win32 getenv implementation

This commit is contained in:
JET 2012-04-03 10:38:48 -06:00
parent 2f225795fc
commit 57092ece0d

View File

@ -632,13 +632,9 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
} }
// System.getEnvironment() implementation // System.getEnvironment() implementation
// TODO: For Win32, replace usage of deprecated _wenviron // TODO: For Win32, replace usage of deprecated _environ and add Unicode
#ifndef PLATFORM_WINDOWS // support (neither of which is likely to be of great importance).
extern char** environ; extern char** environ;
# else
extern wchar_t** _wenviron;
const wchar_t** environ = _wenviron;
#endif
extern "C" JNIEXPORT jobjectArray JNICALL extern "C" JNIEXPORT jobjectArray JNICALL
Java_java_lang_System_getEnvironment(JNIEnv* env, jclass) { Java_java_lang_System_getEnvironment(JNIEnv* env, jclass) {
int length; int length;
@ -649,11 +645,7 @@ Java_java_lang_System_getEnvironment(JNIEnv* env, jclass) {
env->NewStringUTF("")); env->NewStringUTF(""));
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
#ifndef PLATFORM_WINDOWS jobject varString = env->NewStringUTF(environ[i]);
jobject varString = env->NewStringUTF(environ[i]); // UTF-8
#else
jobject varString = env->NewString(environ[i]); // UTF-16
#endif
env->SetObjectArrayElement(stringArray, i, varString); env->SetObjectArrayElement(stringArray, i, varString);
} }