corda/classpath/java-lang.cpp

40 lines
808 B
C++
Raw Normal View History

2007-07-28 16:10:13 +00:00
#include "sys/time.h"
#include "time.h"
#include "time.h"
2007-07-07 23:47:35 +00:00
#include "string.h"
2007-06-25 01:34:07 +00:00
#include "jni.h"
#include "jni-util.h"
2007-06-25 01:34:07 +00:00
2007-06-29 16:42:39 +00:00
#undef JNIEXPORT
#define JNIEXPORT __attribute__ ((visibility("default")))
2007-07-07 23:47:35 +00:00
extern "C" JNIEXPORT jstring JNICALL
Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code)
2007-07-07 23:47:35 +00:00
{
enum {
LineSeparator = 100,
OsName = 101
};
2007-07-07 23:47:35 +00:00
switch (code) {
case LineSeparator:
return e->NewStringUTF("\n");
case OsName:
return e->NewStringUTF("posix");
2007-07-07 23:47:35 +00:00
default:
throwNew(e, "java/lang/RuntimeException", 0);
return 0;
}
2007-07-07 23:47:35 +00:00
}
2007-07-28 16:10:13 +00: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);
}