mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Java: Improve robustness against JVM crashes on exit.
The JVM doesn't always do a good job of telling JNI modules that the JVM is going away, which results in a crash in the JavaGlobal and/or JavaWeakGlobal destructors as they try to delete the associated references after the JVM has already gone away. To protect against this, the Notifier now has a static variable that's set when the Notifier instance (a singleton) is destroyed. This is used by JavaGlobal and JavaWeakGlobal to detect when a process exit is in process.
This commit is contained in:
@@ -10,12 +10,17 @@
|
||||
using namespace nt;
|
||||
|
||||
ATOMIC_STATIC_INIT(Notifier)
|
||||
bool Notifier::s_destroyed = false;
|
||||
|
||||
Notifier::Notifier() {
|
||||
m_active = false;
|
||||
s_destroyed = false;
|
||||
}
|
||||
|
||||
Notifier::~Notifier() { Stop(); }
|
||||
Notifier::~Notifier() {
|
||||
s_destroyed = true;
|
||||
Stop();
|
||||
}
|
||||
|
||||
void Notifier::Start() {
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user