I think i've found a bug on either the jvm or gnome 3. Shutdownhooks are never run on gnome 3 if the application had the EDT activated on shutdown or logout - never never - while they always run/start if the application never used swing/AWT.
If you ignore the commented 'workaround' method on this class: https://gist.github.com/i30817/9421646
(which can actually hose the shutdown even harder by crashing gnome-shell for some reason, although i think i'm in the right track for a workaround)
and run the test like so: java -jar test.jar > test.log
And then try to logout, and log in again, the test log will be empty.
In fact, if you try to run it with this systemtap script (install systemtap, run it like so: sudo stap -o test.log -c "java -jar test.jar" scriptfile.stp )
probe nd_syscall.exit {
if(pid() == target()){
sig = status & 0x7F
code = sig ? sig : status >> 8
log(sprintf("EXIT: %4d %s thread: %s %d\n",
pid(), execname(),
sig ? "signal" : "exit code", code))
}
}
You'll find that the jvm exit values are most definitely not 0 (the 'success' convention that unix and system exit uses), while if you exited while on normal operation they would be. If you went further and tried a byteman script, you'd see the shutdown hooks never even start.
This is to make sure i'm not going crazy and this is a real bug, because i've been getting this since forever, and it's very weird to me that java has been broken for over a year and no one noticed. If you're courageous you could even uncomment the 'workaround' although as i said, that method gave me hangs even on logout. The shutdown hooks do start with it though.