JRuby

JRuby can double slash ("//") the directory given by __FILE__ when "everything" suits this thing to happen. :-)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Not A Bug
  • Affects Version/s: JRuby 1.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

In other words, I can't create a small program to reproduce it because this happens inside of a larger framework,
and so far I failed to reproduce it using a framework-free sample.

But the given files show the summary of it:

File A:

GUI::AppManager.register _FILE_, {
:version => '1.0',
:title => 'JEditor'
}

File B:

def AppManager.register filename, conf = nil
p 'Watch out filename:', filename

The output is:

"Watch out filename:"
"/home/dewd/code/apps/jeditor/gui/lib//jeditor_gui/conf.rb"

Which for me doesn't quite match what is expected, that is, the double slash in
"lib//jeditor_gui" screws things for me. For this one case I was able to normalize
it with File.expand_path and it worked. But I fear it could happen elsewhere still.

This same code works great with Ruby itself and only derails with JRuby.

Maybe if _FILE_ knows that it is returning the full path of the file in question
it could be normalized inside JRuby core so it better matched what Ruby provides
in similar situations.

Activity

Hide
Charles Oliver Nutter added a comment -

So basically _FILE_ is showing the double-slash in the path if you happen to load that file with the double slash, correct?

$ cat test.rb
p __FILE__
$ jruby /Users/headius/projects/jruby//test.rb
"/Users/headius/projects/jruby//test.rb"

So are you saying this behavior is wrong or other File logic is wrong?

Show
Charles Oliver Nutter added a comment - So basically _FILE_ is showing the double-slash in the path if you happen to load that file with the double slash, correct?
$ cat test.rb
p __FILE__
$ jruby /Users/headius/projects/jruby//test.rb
"/Users/headius/projects/jruby//test.rb"
So are you saying this behavior is wrong or other File logic is wrong?
Hide
Joao Pedrosa added a comment -

That's new to me. It's a possibility to how it might occur in my code. There has to be something else going on though, because this issue first appeared with JRuby for code that worked with Ruby just fine.

For example, let's say the file loaded with the extra slash was given the extra slash by JRuby internals somewhere when using commands like "require" or "load", where MRI would not. This would create this discrepancy I am seeing.

But given the example you just showed in the comment above, I figure the solution is not as easy as I first thought when I gave the "normalize when _FILE_ is called" idea.

Speaking of differences, here's a new one, on Windows:

C:\>jruby -v c:\t_\\\\softing
la.rb
jruby 1.1.7 (ruby 1.8.6 patchlevel 287) (2009-01-24 rev ) [x86-java]
"c:\\t_\\\\\\\\softing\\\\la.rb"

C:\>\opt\mingw_ruby-1.8.6\bin\ruby.exe c:\t_\\\\softing
la.rb
"c:/t_////softing//la.rb"

C:\>\opt\mingw_ruby-1.9.1\bin\ruby.exe c:\t_\\\\softing
la.rb
"c:/t_////softing//la.rb"

Perhaps we can close this bug as I could not create a reproducible example and there is not an easy way to circumvent the issue in JRuby core either.

Thanks.

Show
Joao Pedrosa added a comment - That's new to me. It's a possibility to how it might occur in my code. There has to be something else going on though, because this issue first appeared with JRuby for code that worked with Ruby just fine. For example, let's say the file loaded with the extra slash was given the extra slash by JRuby internals somewhere when using commands like "require" or "load", where MRI would not. This would create this discrepancy I am seeing. But given the example you just showed in the comment above, I figure the solution is not as easy as I first thought when I gave the "normalize when _FILE_ is called" idea. Speaking of differences, here's a new one, on Windows: C:\>jruby -v c:\t_\\\\softing
la.rb jruby 1.1.7 (ruby 1.8.6 patchlevel 287) (2009-01-24 rev ) [x86-java] "c:\\t_\\\\\\\\softing\\\\la.rb" C:\>\opt\mingw_ruby-1.8.6\bin\ruby.exe c:\t_\\\\softing
la.rb "c:/t_////softing//la.rb" C:\>\opt\mingw_ruby-1.9.1\bin\ruby.exe c:\t_\\\\softing
la.rb "c:/t_////softing//la.rb" Perhaps we can close this bug as I could not create a reproducible example and there is not an easy way to circumvent the issue in JRuby core either. Thanks.
Hide
Charles Oliver Nutter added a comment -

Let's close it for now and if you're able to sort out where we actually differ from MRI with a reproducible test case, feel free to reopen it.

Show
Charles Oliver Nutter added a comment - Let's close it for now and if you're able to sort out where we actually differ from MRI with a reproducible test case, feel free to reopen it.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: