I finally got fed up with the damned path separator issues on Windows
and took a brute-force (while admittedly naive) approach to fixing it.
I created a subclass of java.io.File called SmartFile and modified
JRuby to use that internally.

It overrides the methods you'd expect: anything that returns a path
string or another File instance now returns a path string with '\'
substituted for '/' and File instances substituted for SmartFile
instances. It also provides alternate implementations of the relevant
File static methods, forcing them to do the same substitution. The net
result is that once a path enters JRuby it will be normalized to '/'
path separators throughout and never use '\' again.

I'm not sure I've captured every place a java.io.File might be
created. Please let me know if I've missed anything.

The ultimate motivator for this was discovering that our config stuff
(RbConfig) uses Windows path separators where Ruby uses Unix path
separators. This was ultimately causing regexps within the RubyGems
installer to fail to match.

I'm not sure if this patch is the answer, but it's high time we made
some modifications within JRuby to normalize all path separators to
'/'. It just won't work with the rest of the Ruby world if we do not.

The patch is applicable to cnutter_work1 and has not been committed anywhere.

- Charlie

Attachment: eliminate_java_io_file.patch
Description: Binary data

Reply via email to