Use pathname.rb as MRI does and restore our native optimizations

* Pathname is a hybrid library both in MRI and JRuby.
* The JRuby native part should match MRI's native part.
* The Ruby part should be identical so it can be easily merged.