Fix dynamic rescue on Java exceptions (issue #1598)