Skip to content

Loading…

Fixes JRUBY-6658 #176

Closed
wants to merge 1 commit into from

3 participants

@alindeman

This is my first attempt at a JRuby contribution, so make sure to sanity check me.

  • If an autoload is defined, yet the constant is defined by other means, another autoload for the same constant does not reset the process.
  • Fixes rubyspec/rubyspec#136 under JRuby
@alindeman alindeman Fixes JRUBY-6658
* If an autoload is defined, yet the constant is defined by other means,
  another autoload for the same constant does not reset the process.
* Fixes https://github.com/rubyspec/rubyspec/pull/136 under JRuby
e2b9339
@csw

Looks reasonable to me. Thanks for taking a stab at that!

@headius
JRuby Team member

It's in! Thanks!

@headius headius closed this
@csw
csw commented

Awesome, thanks @headius!

@alindeman

Cool :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 20, 2012
  1. @alindeman

    Fixes JRUBY-6658

    alindeman committed
    * If an autoload is defined, yet the constant is defined by other means,
      another autoload for the same constant does not reset the process.
    * Fixes https://github.com/rubyspec/rubyspec/pull/136 under JRuby
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/org/jruby/RubyModule.java
View
7 src/org/jruby/RubyModule.java
@@ -3530,8 +3530,11 @@ protected IRubyObject constantTableRemove(String name) {
* Define an autoload. ConstantMap holds UNDEF for the name as an autoload marker.
*/
protected void defineAutoload(String name, IAutoloadMethod loadMethod) {
- storeConstant(name, RubyObject.UNDEF);
- getAutoloadMapForWrite().put(name, new Autoload(loadMethod));
+ Autoload existingAutoload = getAutoloadMap().get(name);
+ if (existingAutoload == null || existingAutoload.getValue() == null) {
+ storeConstant(name, RubyObject.UNDEF);
+ getAutoloadMapForWrite().put(name, new Autoload(loadMethod));
+ }
}
/**
Something went wrong with that request. Please try again.