mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
handle various return types properly in invokeNative2
This commit is contained in:
parent
31cf1754ce
commit
a020a3f6bb
2
makefile
2
makefile
@ -28,7 +28,7 @@ src = src
|
|||||||
classpath = classpath
|
classpath = classpath
|
||||||
test = test
|
test = test
|
||||||
|
|
||||||
input = $(test-build)/GC.class
|
input = $(test-build)/Reflection.class
|
||||||
|
|
||||||
build-cxx = g++
|
build-cxx = g++
|
||||||
build-cc = gcc
|
build-cc = gcc
|
||||||
|
@ -3279,7 +3279,8 @@ invokeNative2(MyThread* t, object method)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* function = pointerValue(t, methodCode(t, method));
|
void* function = pointerValue(t, methodCode(t, method));
|
||||||
unsigned returnType = fieldType(t, methodReturnCode(t, method));
|
unsigned returnCode = methodReturnCode(t, method);
|
||||||
|
unsigned returnType = fieldType(t, returnCode);
|
||||||
uint64_t result;
|
uint64_t result;
|
||||||
|
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
@ -3305,20 +3306,37 @@ invokeNative2(MyThread* t, object method)
|
|||||||
&byteArrayBody(t, methodName(t, method), 0));
|
&byteArrayBody(t, methodName(t, method), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LIKELY(t->exception == 0) and returnType == POINTER_TYPE) {
|
if (LIKELY(t->exception == 0)) {
|
||||||
return result ? *reinterpret_cast<uintptr_t*>(result) : 0;
|
switch (returnCode) {
|
||||||
} else if (BytesPerWord == 8) {
|
case ByteField:
|
||||||
switch (returnType) {
|
case BooleanField:
|
||||||
case INT8_TYPE:
|
return static_cast<int8_t>(result);
|
||||||
case INT16_TYPE:
|
|
||||||
case INT32_TYPE:
|
case CharField:
|
||||||
// force sign extension
|
return static_cast<uint16_t>(result);
|
||||||
|
|
||||||
|
case ShortField:
|
||||||
|
return static_cast<int16_t>(result);
|
||||||
|
|
||||||
|
case FloatField:
|
||||||
|
case IntField:
|
||||||
return static_cast<int32_t>(result);
|
return static_cast<int32_t>(result);
|
||||||
|
|
||||||
default: return result;
|
case LongField:
|
||||||
|
case DoubleField:
|
||||||
|
return result;
|
||||||
|
|
||||||
|
case ObjectField:
|
||||||
|
return static_cast<uintptr_t>(result) ? *reinterpret_cast<uintptr_t*>
|
||||||
|
(static_cast<uintptr_t>(result)) : 0;
|
||||||
|
|
||||||
|
case VoidField:
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
default: abort(t);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user