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-1345

Files added to a module via Kernel.autoload are not automatically loaded if the class they contain is extended

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Not A Bug
  • Affects Version/s: JRuby 1.1.1
  • Fix Version/s: JRuby 1.2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Testcase included:
    yes

Description

Discovered while trying to run a Rails project under JRuby. The project makes use of ActiveScaffold and a second plugin that extends ActiveScaffold.
AS uses autoload for all the files in its library.
The second plugin extends one of the classes in AS in the following way:

module Foo::Bar
class Baz
def a_method_new
end
alias_method_chain :a_method, :new
end
end

This works in MRI but in JRuby, the Foo::Bar::Baz class is not autoloaded and the alias causes the application to crash with an "undefined method" NameError

Attached is a test case that demonstrates the problem. Expand the zip into the vendor/plugins directory of a new rails project and attempt to start the project via jruby script/server

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

Attachments

  1. Hide
    Zip Archive
    overriding_plugins.zip
    13/Sep/07 1:24 PM
    2 kB
    Daniel Einspanjer
    1. File
      first_plugin/environment.rb 0.7 kB
    2. File
      first_plugin/init.rb 0.0 kB
    3. File
      first_plugin/lib/config/base.rb 0.1 kB
    4. File
      first_plugin/lib/config/core.rb 0.1 kB
    5. File
      first_plugin/lib/first_plugin.rb 0.1 kB
    6. File
      second_plugin/init.rb 0.0 kB
    7. File
      second_plugin/lib/second.rb 0.4 kB
    Download Zip
    Show
    Zip Archive
    overriding_plugins.zip
    13/Sep/07 1:24 PM
    2 kB
    Daniel Einspanjer

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Charles Oliver Nutter added a comment - 19/Oct/07 9:32 PM

Can you try this out again on trunk and 1.0 branch and see if it's still a problem? There have been a few autoload-related fixes since you reported this.

Show
Charles Oliver Nutter added a comment - 19/Oct/07 9:32 PM Can you try this out again on trunk and 1.0 branch and see if it's still a problem? There have been a few autoload-related fixes since you reported this.
Hide
Permalink
Charles Oliver Nutter added a comment - 12/May/08 3:33 PM

This does appear to still be failing in JRuby 1.1.1. Assigning to Tom to take a look before 1.1.2, since it might be easy (what with him being the autoload king and all).

Show
Charles Oliver Nutter added a comment - 12/May/08 3:33 PM This does appear to still be failing in JRuby 1.1.1. Assigning to Tom to take a look before 1.1.2, since it might be easy (what with him being the autoload king and all).
Hide
Permalink
Charles Oliver Nutter added a comment - 27/May/08 12:03 PM

I think we're going to need to punt this and do some homework (and hopefully get help). My naive attempt to reproduce the problem seems to work ok, so there's something more going on here.

a.rb

module Foo
  module Bar
    autoload :Baz, "b.rb"

    class Baz
      def y
        'wah'
      end
    end
  end
end

a = Foo::Bar::Baz.new
a.x
a.y

b.rb

module Foo
  module Bar
    class Baz
      def x
        'yay'
      end
    end
  end
end
Show
Charles Oliver Nutter added a comment - 27/May/08 12:03 PM I think we're going to need to punt this and do some homework (and hopefully get help). My naive attempt to reproduce the problem seems to work ok, so there's something more going on here. a.rb
module Foo
  module Bar
    autoload :Baz, "b.rb"

    class Baz
      def y
        'wah'
      end
    end
  end
end

a = Foo::Bar::Baz.new
a.x
a.y
b.rb
module Foo
  module Bar
    class Baz
      def x
        'yay'
      end
    end
  end
end
Hide
Permalink
Charles Oliver Nutter added a comment - 14/Jul/08 11:28 PM

Without a better test case or followup from the reporter, this is in danger of getting closed as "incomplete". Please provide a test case for the issue or help us diagnose it further please

Show
Charles Oliver Nutter added a comment - 14/Jul/08 11:28 PM Without a better test case or followup from the reporter, this is in danger of getting closed as "incomplete". Please provide a test case for the issue or help us diagnose it further please
Hide
Permalink
Daniel Einspanjer added a comment - 15/Jul/08 5:41 AM

If the test case I posted no longer reproduces the issue then I'd say it would be fine to close the issue as works for me or something.
Unfortunately, I'm not currently doing any Ruby development so I don't have a sandbox handy to try to reproduce it again.

Show
Daniel Einspanjer added a comment - 15/Jul/08 5:41 AM If the test case I posted no longer reproduces the issue then I'd say it would be fine to close the issue as works for me or something. Unfortunately, I'm not currently doing any Ruby development so I don't have a sandbox handy to try to reproduce it again.
Hide
Permalink
Charles Oliver Nutter added a comment - 16/Jul/08 12:43 AM

Sorry about that, I was able to reproduce it following your original instructions. I'm not going to be able to look at this, but maybe Tom will...

Show
Charles Oliver Nutter added a comment - 16/Jul/08 12:43 AM Sorry about that, I was able to reproduce it following your original instructions. I'm not going to be able to look at this, but maybe Tom will...
Hide
Permalink
Thomas E Enebo added a comment - 17/Jul/08 2:44 AM

I tried this and I do not think I have did enough to reproduce this....

I installed Rails 2.0.2 (Rails 2.1 does not seem compatible with AS).

I then installed AS: ./script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold

I unzipped into vendor/plugins the zip provided..I get the following error in both MRI and JRuby trunk (and it appears that autoload seems to be finding plugin1):

enebo:01:27 ~/workspace/jruby_trunk/hoh 953% /usr/bin/ruby script/server 
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
FirstPlugin module loaded
Exiting
/Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:77:in `evaluate_init_rb': undefined method `configuration' for "second.rb":String (NoMethodError)
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:75:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:39:in `load'
	from /Users/enebo/workspace/jruby_trunk/hoh/vendor/plugins/second_plugin/init.rb:1:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:79:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:75:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:39:in `load'
	 ... 34 levels...
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from script/server:3
Show
Thomas E Enebo added a comment - 17/Jul/08 2:44 AM I tried this and I do not think I have did enough to reproduce this.... I installed Rails 2.0.2 (Rails 2.1 does not seem compatible with AS). I then installed AS: ./script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold I unzipped into vendor/plugins the zip provided..I get the following error in both MRI and JRuby trunk (and it appears that autoload seems to be finding plugin1):
enebo:01:27 ~/workspace/jruby_trunk/hoh 953% /usr/bin/ruby script/server 
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
FirstPlugin module loaded
Exiting
/Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:77:in `evaluate_init_rb': undefined method `configuration' for "second.rb":String (NoMethodError)
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:75:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:39:in `load'
	from /Users/enebo/workspace/jruby_trunk/hoh/vendor/plugins/second_plugin/init.rb:1:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:79:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:75:in `evaluate_init_rb'
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:39:in `load'
	 ... 34 levels...
	from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from script/server:3
Hide
Permalink
Thomas E Enebo added a comment - 17/Jul/08 6:58 PM

Bumping...not getting done today

Show
Thomas E Enebo added a comment - 17/Jul/08 6:58 PM Bumping...not getting done today
Hide
Permalink
Charles Oliver Nutter added a comment - 08/Feb/09 11:40 AM

I'm going to have to mark this as "won't fix" because the attached example fails the exact same way under MRI and we have no other example to go on. If you can come up with a reduced case, we can certainly reopen this bug or open a new one that's more specific.

Show
Charles Oliver Nutter added a comment - 08/Feb/09 11:40 AM I'm going to have to mark this as "won't fix" because the attached example fails the exact same way under MRI and we have no other example to go on. If you can come up with a reduced case, we can certainly reopen this bug or open a new one that's more specific.

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Daniel Einspanjer
Vote (0)
Watch (2)

Dates

  • Created:
    13/Sep/07 1:24 PM
    Updated:
    21/Mar/09 1:14 PM
    Resolved:
    08/Feb/09 11:40 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.