Kernel#fail should handle java exceptions

Fixes #1641