Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.5
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:OS:Windows XP SP2
Jruby version:1.5.6 and 1.6.5
-
Number of attachments :
Description
Assume that we have a directory ,the directory name contains none ascii character(such like "照片",means photo in chinese)。
try Dir.entries(directoryname)
under ruby1.8.6,the method works ok.
under jruby 1.5.6 and jruby 1.6.5,the error is "No such file or directory - No such directory"
Activity
Hiro Asari
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
Assume that we have a directory ,the directory name contains none ascii character(such like "照片",means photo in chinese)。
try Dir.entries(directoryname); under ruby1.8.6,the method works ok. under jruby1.5.6andjruby1.6.5,the error is "No such file or directory - No such directory" |
Assume that we have a directory ,the directory name contains none ascii character(such like "照片",means photo in chinese)。
try {{Dir.entries(directoryname)}} under ruby1.8.6,the method works ok. under jruby 1.5.6 and jruby 1.6.5,the error is "No such file or directory - No such directory" |
Charles Oliver Nutter
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Charles Oliver Nutter [ headius ] | |
| Fix Version/s | JRuby 1.7 [ 17049 ] | |
| Resolution | Fixed [ 1 ] |
I have reproduced the issue.
For 1.9 mode (currently default for master), top of the stacktrace is:
RubyString.getUnicodeValue() line: 7628
RubyDir.getPath19(ThreadContext, IRubyObject) line: 735
RubyDir.entries19(ThreadContext, IRubyObject, IRubyObject) line: 367
The problem is the path of type RubyString is converted to java.lang.String via method RubyEncoding.decodeUTF8, which assumes the RubyString got passed in is a UTF-8 byte list, it would fail for all not-ASCII-compatible locales, especially CJK-ish Windows.
Checking RubyString class, I found the methods decodeString() and the wrappers asJavaString(), toString() can correctly handle this.