JRuby

loading rake breaks import

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: JRuby 1.1.5
  • Fix Version/s: None
  • Component/s: Java Integration
  • Labels:
    None
  • Number of attachments :
    0

Description

irb(main):001:0> require 'rake'
require 'rake'
=> true
irb(main):002:0> import 'java.net.URL'
import 'java.net.URL'
=> ["java.net.URL"]
irb(main):003:0> URL
URL
NameError: uninitialized constant URL
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/ruby-token.rb:46:in `const_missing'
from /home/phil/bin/jruby-1.1.5/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2465:in `const_missing'
from (irb):4:in `irb_binding'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/workspace.rb:53:in `eval'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/workspace.rb:81:in `evaluate'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/context.rb:219:in `evaluate'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb.rb:150:in `eval_input'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb.rb:259:in `signal_status'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/ruby-lex.rb:244:in `each_top_level_statement'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/ruby-lex.rb:230:in `loop'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/ruby-lex.rb:230:in `each_top_level_statement'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/ruby-lex.rb:229:in `catch'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb/ruby-lex.rb:229:in `each_top_level_statement'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb.rb:70:in `start'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb.rb:69:in `catch'
from /home/phil/bin/jruby-1.1.5/lib/ruby/1.8/irb.rb:69:in `start'
from /home/phil/bin/jruby-1.1.5/bin/jirb:19Maybe IRB bug!!
irb(main):004:0>

Activity

Hide
Phil Hagelberg added a comment -

Can't believe I didn't realize this sooner: rake defines Object#import. Ouch!

Show
Phil Hagelberg added a comment - Can't believe I didn't realize this sooner: rake defines Object#import. Ouch!
Hide
Phil Hagelberg added a comment -

Tracking this in Rake as well. http://onestepback.org/redmine/issues/show/38

If it doesn't get moved in Rake, we could either:

(0) - fix it in the copy of rake that gets bundled with JRuby (but this will break if rake gets upgraded)

or

(1) deprecate import in favour of import_java?

Rake is very widely-used for testing, so telling people to use "import" when it will break in their tests seems questionable.

Show
Phil Hagelberg added a comment - Tracking this in Rake as well. http://onestepback.org/redmine/issues/show/38 If it doesn't get moved in Rake, we could either: (0) - fix it in the copy of rake that gets bundled with JRuby (but this will break if rake gets upgraded) or (1) deprecate import in favour of import_java? Rake is very widely-used for testing, so telling people to use "import" when it will break in their tests seems questionable.
Hide
Andrew Davey added a comment -

For those of you playing from home, using 'java_import' instead of 'import' gets around this issue with Rake.

Show
Andrew Davey added a comment - For those of you playing from home, using 'java_import' instead of 'import' gets around this issue with Rake.
Hide
Ben Kitzelman added a comment -

Thanks Andy - that was the solution - and I'm up and running.

Show
Ben Kitzelman added a comment - Thanks Andy - that was the solution - and I'm up and running.
Hide
Charles Oliver Nutter added a comment -

Marking WONTFIX. Just an unfortunate coincidence, and java_import gets around it neatly.

Show
Charles Oliver Nutter added a comment - Marking WONTFIX. Just an unfortunate coincidence, and java_import gets around it neatly.
Hide
Valters Vingolds added a comment -

By the way, if you are building Rails project, and you use Google's appengine-jruby SDK, then Rake will stop working on you - because of this issue.

In appengine-ruby they use 'import' to take Java classes, and this confuses Rake and it fails.
I mean, even 'rake routes' will not work.
(So somebody tell appengine-jruby folks to use java_import instead).

Show
Valters Vingolds added a comment - By the way, if you are building Rails project, and you use Google's appengine-jruby SDK, then Rake will stop working on you - because of this issue. In appengine-ruby they use 'import' to take Java classes, and this confuses Rake and it fails. I mean, even 'rake routes' will not work. (So somebody tell appengine-jruby folks to use java_import instead).
Hide
Valters Vingolds added a comment -

My point is, maybe 'import' should be deprecated in favour of 'java_import', to avoid this type of problem.

Show
Valters Vingolds added a comment - My point is, maybe 'import' should be deprecated in favour of 'java_import', to avoid this type of problem.
Hide
Charles Oliver Nutter added a comment -

Valters: I agree...and there's actually a bug for that. I am encouraging people to use java_import as much as I can (and when I can remember) but mentioning that the shortcut "import" exists with caveats. Perhaps we should actually have a deprecation warning go out in 1.4?

Show
Charles Oliver Nutter added a comment - Valters: I agree...and there's actually a bug for that. I am encouraging people to use java_import as much as I can (and when I can remember) but mentioning that the shortcut "import" exists with caveats. Perhaps we should actually have a deprecation warning go out in 1.4?

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: