Skip to content

JRuby 1.7.12: File.read("") throws Java ArrayIndexOutOfBoundsException #1726

@aetherknight

Description

@aetherknight

When I perform a File.read('') with JRuby 1.7.12, JRuby raises a Java ArrayIndexOutOfBoundsException instead of a Ruby Errno::ENOENT exception.

Expected behavior

$ ruby -e 'File.read("")'
-e:1:in `read': No such file or directory -  (Errno::ENOENT)
    from -e:1:in `<main>'

This is true with both MRI 1.9.3 and 2.0.0:

$ ruby --version
ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-darwin13.2.0]

$ ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-darwin12.5.0]

Observed behavior

$ jruby -e 'File.read("")'
EncodingUtils.java:597:in `encAscget': java.lang.ArrayIndexOutOfBoundsException: 0
    from RubyIO.java:3841:in `checkPipeCommand'
    from RubyIO.java:3829:in `ioOpen'
    from RubyIO.java:3796:in `openKeyArgs'
    from RubyIO.java:3776:in `read19'
    from RubyIO.java:3955:in `read19'
    from RubyIO$INVOKER$s$0$3$read19.gen:-1:in `call'
    from DynamicMethod.java:210:in `call'
    from DynamicMethod.java:206:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from -e:1:in `__file__'
    from -e:-1:in `load'
    from Ruby.java:811:in `runScript'
    from Ruby.java:804:in `runScript'
    from Ruby.java:673:in `runNormally'
    from Ruby.java:522:in `runFromMain'
    from Main.java:395:in `doRunFromMain'
    from Main.java:290:in `internalRun'
    from Main.java:217:in `run'
    from Main.java:197:in `main'

Version details:

$ jruby --version
jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_55-b13 [darwin-x86_64]

$ java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions