0
不知道dataArray
的~JniFloatArray
是否被調用,當com/emcjpn/sleep/SleepAlgorithmBreakException
被拋出?從JNI函數拋出java異常之後調用C++析構函數嗎?
JNIEXPORT jobject JNICALL Java_com_emcjpn_sleep_SleepAlgorithm_nativePushNewDataAndCalculate(JNIEnv *env, jclass type,
jlong ptr, jfloatArray data_) {
JniFloatArray dataArray(data_, env);
jfloat *data = dataArray.getData();
SleepAlgorithm* algorithm = (SleepAlgorithm*)ptr;
jsize length = dataArray.length();
SleepAlgorithmResult result = algorithm->pushNewDataAndCalculate(data, data + length);
if (result.shouldBreak) {
jclass exception = env->FindClass("com/emcjpn/sleep/SleepAlgorithmBreakException");
env->ThrowNew(exception, "sleep calculation failed, invalid ecg data");
return NULL;
}
/*Some other code*/
}
您是否嘗試在析構函數中放置斷點? – efekctive
好主意。我會嘗試 –