add GetArrayLength, NewObject, NewObjectV, MonitorEnter, and MonitorExit JNIEnv methods

This commit is contained in:
Joel Dice 2007-11-14 16:22:29 -07:00
parent 69f1024887
commit 115622f54a

View File

@ -100,6 +100,14 @@ ReleaseStringUTFChars(Thread* t, jstring, const char* chars)
t->m->system->free(chars);
}
jsize JNICALL
GetArrayLength(Thread* t, jarray array)
{
ENTER(t, Thread::ActiveState);
return cast<uintptr_t>(*array, BytesPerWord);
}
jstring JNICALL
NewString(Thread* t, const jchar* chars, jsize size)
{
@ -262,6 +270,32 @@ getMethod(Thread* t, object o, jmethodID m)
}
}
jobject JNICALL
NewObjectV(Thread* t, jclass c, jmethodID m, va_list a)
{
ENTER(t, Thread::ActiveState);
object o = make(t, *c);
PROTECT(t, o);
t->m->processor->invokeList(t, getMethod(t, o, m), o, true, a);
return makeLocalReference(t, o);
}
jobject JNICALL
NewObject(Thread* t, jclass c, jmethodID m, ...)
{
va_list a;
va_start(a, m);
jobject r = NewObject(t, c, m, a);
va_end(a);
return r;
}
jobject JNICALL
CallObjectMethodV(Thread* t, jobject o, jmethodID m, va_list a)
{
@ -1496,7 +1530,10 @@ GetBooleanArrayRegion(Thread* t, jbooleanArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
memcpy(dst, &booleanArrayBody(t, *array, offset), length * sizeof(jboolean));
if (length) {
memcpy(dst, &booleanArrayBody(t, *array, offset),
length * sizeof(jboolean));
}
}
void JNICALL
@ -1505,8 +1542,10 @@ GetByteArrayRegion(Thread* t, jbyteArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(dst, &byteArrayBody(t, *array, offset), length * sizeof(jbyte));
}
}
void JNICALL
GetCharArrayRegion(Thread* t, jcharArray array, jint offset, jint length,
@ -1514,8 +1553,10 @@ GetCharArrayRegion(Thread* t, jcharArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(dst, &charArrayBody(t, *array, offset), length * sizeof(jchar));
}
}
void JNICALL
GetShortArrayRegion(Thread* t, jshortArray array, jint offset, jint length,
@ -1523,8 +1564,10 @@ GetShortArrayRegion(Thread* t, jshortArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(dst, &shortArrayBody(t, *array, offset), length * sizeof(jshort));
}
}
void JNICALL
GetIntArrayRegion(Thread* t, jintArray array, jint offset, jint length,
@ -1532,8 +1575,10 @@ GetIntArrayRegion(Thread* t, jintArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(dst, &intArrayBody(t, *array, offset), length * sizeof(jint));
}
}
void JNICALL
GetLongArrayRegion(Thread* t, jlongArray array, jint offset, jint length,
@ -1541,8 +1586,10 @@ GetLongArrayRegion(Thread* t, jlongArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(dst, &longArrayBody(t, *array, offset), length * sizeof(jlong));
}
}
void JNICALL
GetFloatArrayRegion(Thread* t, jfloatArray array, jint offset, jint length,
@ -1550,8 +1597,10 @@ GetFloatArrayRegion(Thread* t, jfloatArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(dst, &floatArrayBody(t, *array, offset), length * sizeof(jfloat));
}
}
void JNICALL
GetDoubleArrayRegion(Thread* t, jdoubleArray array, jint offset, jint length,
@ -1559,8 +1608,10 @@ GetDoubleArrayRegion(Thread* t, jdoubleArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(dst, &doubleArrayBody(t, *array, offset), length * sizeof(jdouble));
}
}
void JNICALL
SetBooleanArrayRegion(Thread* t, jbooleanArray array, jint offset, jint length,
@ -1568,7 +1619,10 @@ SetBooleanArrayRegion(Thread* t, jbooleanArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
memcpy(&booleanArrayBody(t, *array, offset), src, length * sizeof(jboolean));
if (length) {
memcpy(&booleanArrayBody(t, *array, offset), src,
length * sizeof(jboolean));
}
}
void JNICALL
@ -1577,8 +1631,10 @@ SetByteArrayRegion(Thread* t, jbyteArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(&byteArrayBody(t, *array, offset), src, length * sizeof(jbyte));
}
}
void JNICALL
SetCharArrayRegion(Thread* t, jcharArray array, jint offset, jint length,
@ -1586,8 +1642,10 @@ SetCharArrayRegion(Thread* t, jcharArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(&charArrayBody(t, *array, offset), src, length * sizeof(jchar));
}
}
void JNICALL
SetShortArrayRegion(Thread* t, jshortArray array, jint offset, jint length,
@ -1595,8 +1653,10 @@ SetShortArrayRegion(Thread* t, jshortArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(&shortArrayBody(t, *array, offset), src, length * sizeof(jshort));
}
}
void JNICALL
SetIntArrayRegion(Thread* t, jintArray array, jint offset, jint length,
@ -1604,8 +1664,10 @@ SetIntArrayRegion(Thread* t, jintArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(&intArrayBody(t, *array, offset), src, length * sizeof(jint));
}
}
void JNICALL
SetLongArrayRegion(Thread* t, jlongArray array, jint offset, jint length,
@ -1613,8 +1675,10 @@ SetLongArrayRegion(Thread* t, jlongArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(&longArrayBody(t, *array, offset), src, length * sizeof(jlong));
}
}
void JNICALL
SetFloatArrayRegion(Thread* t, jfloatArray array, jint offset, jint length,
@ -1622,8 +1686,10 @@ SetFloatArrayRegion(Thread* t, jfloatArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(&floatArrayBody(t, *array, offset), src, length * sizeof(jfloat));
}
}
void JNICALL
SetDoubleArrayRegion(Thread* t, jdoubleArray array, jint offset, jint length,
@ -1631,8 +1697,10 @@ SetDoubleArrayRegion(Thread* t, jdoubleArray array, jint offset, jint length,
{
ENTER(t, Thread::ActiveState);
if (length) {
memcpy(&doubleArrayBody(t, *array, offset), src, length * sizeof(jdouble));
}
}
void* JNICALL
GetPrimitiveArrayCritical(Thread* t, jarray array, jboolean* isCopy)
@ -1656,6 +1724,26 @@ ReleasePrimitiveArrayCritical(Thread* t, jarray, void*, jint)
}
}
jint JNICALL
MonitorEnter(Thread* t, jobject o)
{
ENTER(t, Thread::ActiveState);
acquire(t, *o);
return 0;
}
jint JNICALL
MonitorExit(Thread* t, jobject o)
{
ENTER(t, Thread::ActiveState);
release(t, *o);
return 0;
}
jint JNICALL
GetJavaVM(Thread* t, Machine** m)
{
@ -1714,6 +1802,7 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable)
envTable->GetStringUTFLength = ::GetStringUTFLength;
envTable->GetStringUTFChars = ::GetStringUTFChars;
envTable->ReleaseStringUTFChars = ::ReleaseStringUTFChars;
envTable->GetArrayLength = ::GetArrayLength;
envTable->NewString = ::NewString;
envTable->NewStringUTF = ::NewStringUTF;
envTable->FindClass = ::FindClass;
@ -1725,6 +1814,8 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable)
envTable->GetFieldID = ::GetFieldID;
envTable->GetMethodID = ::GetMethodID;
envTable->GetStaticMethodID = ::GetStaticMethodID;
envTable->NewObject = ::NewObject;
envTable->NewObjectV = ::NewObjectV;
envTable->CallObjectMethodV = ::CallObjectMethodV;
envTable->CallObjectMethod = ::CallObjectMethod;
envTable->CallBooleanMethodV = ::CallBooleanMethodV;
@ -1852,6 +1943,8 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable)
envTable->SetDoubleArrayRegion = ::SetDoubleArrayRegion;
envTable->GetPrimitiveArrayCritical = ::GetPrimitiveArrayCritical;
envTable->ReleasePrimitiveArrayCritical = ::ReleasePrimitiveArrayCritical;
envTable->MonitorEnter = MonitorEnter;
envTable->MonitorExit = MonitorExit;
envTable->GetJavaVM = ::GetJavaVM;
envTable->IsSameObject = ::IsSameObject;
}