Fixing hashing consistency across JVM instances.

Fixing an older pull request [#590] by squashing the commits into one.

[#590]: https://github.com/jruby/jruby/pull/590