jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-31

Dir['.'] generates Java exception

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 0.9.0
  • Fix Version/s: JRuby 0.9.1
  • Component/s: Java Integration
  • Labels:
    None
  • Environment:
    JRuby 0.9.0
  • Testcase included:
    yes

Description

Evaluate the following expression in JIRB:
Dir['.']

Under Ruby's IRB, this returns the following:
=> ["."]

Under JRuby 0.9.0's JIRB, the following happens:

irb(main):005:0> Dir['.']
NativeException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
from java.lang.String.substring(String.java:1768)
from java.lang.String.substring(String.java:1735)
from org.jruby.util.Glob$GlobPattern.getMatchedFiles(Glob.java:308)
from org.jruby.util.Glob.getNames(Glob.java:198)
from org.jruby.RubyDir.glob(RubyDir.java:144)
from sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
from sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
from sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
from java.lang.reflect.Method.invoke(Method.java:585)
from org.jruby.runtime.callback.ReflectionCallback.execute(ReflectionCallback.java:140)
from org.jruby.internal.runtime.methods.CallbackMethod.internalCall(CallbackMethod.java:79)
from org.jruby.internal.runtime.methods.AbstractMethod.call(AbstractMethod.java:51)
from org.jruby.RubyObject.callMethod(RubyObject.java:362)
from org.jruby.RubyObject.callMethod(RubyObject.java:316)
from org.jruby.evaluator.EvaluateVisitor$CallNodeVisitor.execute(EvaluateVisitor.java:555)
from org.jruby.evaluator.EvaluationState.executeNext(EvaluationState.java:262)
... 318 levels...
from org.jruby.Main.runInterpreter(Main.java:176)
from org.jruby.Main.runInterpreter(Main.java:145)
from org.jruby.Main.run(Main.java:111)
from org.jruby.Main.main(Main.java:86)
from (irb):1
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:150:in `eval_input'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:70:in `signal_status'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:189:in `eval_input'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:70:in `each_top_level_statement'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:190:in `loop'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:190:in `catch'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:190:in `eval_input'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:70:in `start'
from C:\third-party\jruby-0.9.0\bin\jirb:13:in `catch'
from C:/third-party/jruby-0.9.0/lib/ruby/1.8/irb.rb:71:in `start'
from C:\third-party\jruby-0.9.0\bin\jirb:13irb(main)

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    31.patch
    20/Jul/06 8:01 AM
    1 kB
    Miguel Covarrubias

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Eric Kramer added a comment - 19/Jul/06 7:55 AM

Here's another non-conformity that could be related. In this example we're in a directory that has one subdirectory named 'abc'

Via Ruby:
Dir['./abc'] # => ["./abc"]

Via JRuby
Dir['./abc'] # => ["abc"]

Both responses are technically correct, but I wonder if perhaps there's some special handling of '.' that may be required within JRuby.

Show
Eric Kramer added a comment - 19/Jul/06 7:55 AM Here's another non-conformity that could be related. In this example we're in a directory that has one subdirectory named 'abc' Via Ruby: Dir['./abc'] # => ["./abc"] Via JRuby Dir['./abc'] # => ["abc"] Both responses are technically correct, but I wonder if perhaps there's some special handling of '.' that may be required within JRuby.
Hide
Permalink
Miguel Covarrubias added a comment - 20/Jul/06 8:01 AM

Here's a patch that at least seems to take care of the exception problem though not the nonconformities:

Interpreter 'ruby' invoking Dir['./jruby']:
./jruby

Interpreter 'ruby' invoking Dir['.']:
.

Interpreter 'jruby' invoking Dir['./jruby']:
jruby

Interpreter 'jruby' invoking Dir['.']:
/Users/mcovarru/Documents/workspace

As you say, the paths are technically equivalent, but the nonconformities make me nervous too.

Show
Miguel Covarrubias added a comment - 20/Jul/06 8:01 AM Here's a patch that at least seems to take care of the exception problem though not the nonconformities: Interpreter 'ruby' invoking Dir['./jruby']: ./jruby Interpreter 'ruby' invoking Dir['.']: . Interpreter 'jruby' invoking Dir['./jruby']: jruby Interpreter 'jruby' invoking Dir['.']: /Users/mcovarru/Documents/workspace As you say, the paths are technically equivalent, but the nonconformities make me nervous too.
Hide
Permalink
Thomas E Enebo added a comment - 20/Jul/06 9:25 AM

I am closing this since the original problem reported is fixed by the applied patch. I opened up JRUBY-36 in which hopefully I captured all from the comments here and added some additional information for the general inconsistencies in Dir[]

Show
Thomas E Enebo added a comment - 20/Jul/06 9:25 AM I am closing this since the original problem reported is fixed by the applied patch. I opened up JRUBY-36 in which hopefully I captured all from the comments here and added some additional information for the general inconsistencies in Dir[]
Hide
Permalink
Eric Kramer added a comment - 20/Jul/06 9:02 PM

Nice work.

Show
Eric Kramer added a comment - 20/Jul/06 9:02 PM Nice work.
Hide
Permalink
Charles Oliver Nutter added a comment - 08/Dec/06 12:25 PM

Closing 0.9.1 resolved issues.

Show
Charles Oliver Nutter added a comment - 08/Dec/06 12:25 PM Closing 0.9.1 resolved issues.

People

  • Assignee:
    Unassigned
    Reporter:
    Eric Kramer
Vote (0)
Watch (0)

Dates

  • Created:
    18/Jul/06 3:49 PM
    Updated:
    08/Dec/06 12:25 PM
    Resolved:
    20/Jul/06 9:25 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.