re-implement System.getProperty to separate vm-specific properties from others

This commit is contained in:
Joel Dice
2007-08-27 07:46:17 -06:00
parent 493667a6cc
commit b8de552797
7 changed files with 105 additions and 30 deletions

View File

@ -3,26 +3,30 @@
#include "time.h"
#include "string.h"
#include "jni.h"
#include "jni-util.h"
#undef JNIEXPORT
#define JNIEXPORT __attribute__ ((visibility("default")))
extern "C" JNIEXPORT jstring JNICALL
Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring key)
Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code)
{
jstring value = 0;
enum {
LineSeparator = 100,
OsName = 101
};
const char* chars = e->GetStringUTFChars(key, 0);
if (chars) {
if (strcmp(chars, "line.separator") == 0) {
value = e->NewStringUTF("\n");
} else if (strcmp(chars, "os.name") == 0) {
value = e->NewStringUTF("posix");
}
e->ReleaseStringUTFChars(key, chars);
switch (code) {
case LineSeparator:
return e->NewStringUTF("\n");
case OsName:
return e->NewStringUTF("posix");
default:
throwNew(e, "java/lang/RuntimeException", 0);
return 0;
}
return value;
}
extern "C" JNIEXPORT jlong JNICALL