Skip to content
Browse files

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
  • Loading branch information...
1 parent 2ef7719 commit e2b933926c259a40534922e45f77f952bec90558 @alindeman committed May 20, 2012
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));
+ }
}
/**

0 comments on commit e2b9339

Please sign in to comment.
Something went wrong with that request. Please try again.