Hack-ish workaround for JRUBY-7134 that restores $! when an exception is thrown when checking whether the dir exists.
Added also pull request for rubyspec.
Restore 29170 when catching exception.
This works, but I am a bit worried about committing this. I have not looked at MRI source, but ideally we should add smarts to FileStat to avoid setting $! in the first place if the operand is a directory.
Yup. As I said, hack-ish. The alternative is to modify jnr-posix directly, or amend JRubyPOSIXHandler to interact with it, but I was a bit reluctant to do that.