corda/classpath/java-lang.cpp

34 lines
763 B
C++
Raw Normal View History

2007-07-28 10:10:13 -06:00
#include "sys/time.h"
#include "time.h"
#include "time.h"
2007-07-07 17:47:35 -06:00
#include "string.h"
2007-06-24 19:34:07 -06:00
#include "jni.h"
2007-06-29 10:42:39 -06:00
#undef JNIEXPORT
#define JNIEXPORT __attribute__ ((visibility("default")))
2007-07-07 17:47:35 -06:00
extern "C" JNIEXPORT jstring JNICALL
Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring key)
2007-07-07 17:47:35 -06:00
{
jstring value = 0;
const char* chars = e->GetStringUTFChars(key, 0);
2007-07-07 17:47:35 -06:00
if (chars) {
if (strcmp(chars, "line.separator") == 0) {
value = e->NewStringUTF("\n");
}
e->ReleaseStringUTFChars(key, chars);
2007-07-07 17:47:35 -06:00
}
return value;
}
2007-07-28 10:10:13 -06:00
extern "C" JNIEXPORT jlong JNICALL
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
{
timeval tv = { 0, 0 };
gettimeofday(&tv, 0);
return (static_cast<jlong>(tv.tv_sec) * 1000) +
(static_cast<jlong>(tv.tv_usec) / 1000);
}