mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
JavaGlobal was unconditionally attaching to (okay) and detaching from (bad) the current thread during destruction. We don't want to do this if the destructor gets called from an attached thread. Instead, use GetEnv to first try to get the environment, and only attach and detach if it returns an error saying the thread is detached. Also, make sure notifier callbacks appropriately free Java locals to avoid running out of local variable space.