[wpilibj] Call abort() on Rio on caught Java exception (#6420)

On Rio, we simply want to restart the robot program as quickly as possible,
and don't want to risk a hang somewhere that will keep that from happening.

The main downside of this is it won't wait for threads to finish (e.g. data logs won't get a final flush).
This commit is contained in:
Peter Johnson
2024-03-09 09:55:49 -08:00
committed by GitHub
parent ccb4cbed63
commit 18e57f7872
3 changed files with 23 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
#include <jni.h>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <fmt/format.h>
@@ -82,6 +83,20 @@ Java_edu_wpi_first_hal_HAL_exitMain
HAL_ExitMain();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: terminate
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_terminate
(JNIEnv*, jclass)
{
#ifdef __FRC_ROBORIO__
std::abort();
#endif
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: simPeriodicBeforeNative