Make ClassIndex into an enum, to prevent issues like #1004.
Always log unhandled exceptions in threads.

This is JRuby's fix for https://bugs.ruby-lang.org/issues/6647
which modifies unhandled exception logic in threads to always
log if abort_on_exception != true. This will help avoid the issue
of threads silently disappearing.
Make def return the name as a symbol rather than nil.

This is for 2.1 support, but has no significant impact on earlier
compatibility.
Move exitedException capture above other logic, to ensure it sets.