jruby/jruby — pull request #280 by dontfidget (2012-09-03 22:59:06+00:00)
Title: Kernel require

In jruby, the autoload mechanism doesn't actually call Kernel.require like the rubydocs claims it will. This change attempts to fix that.

From http://www.ruby-doc.org/core-1.9.3/Module.html#method-i-autoload:

autoload(module, filename) → nil click to toggle source

Registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed in the namespace of mod.

Note that this change uses the context when autoload is called rather than the context at the time when the require will happen. I wasn't sure what the right thing to do is, or how much it really matters or not.

The purpose of this change is to allow the user to override Kernel.require even with autoloading. rubygems is presmably the most well-known overrider of Kernel.require. It presumably it ends up pulling in enough stuff into LOAD_PATH via direct requires that any autoloading it does still works, but I suspect it could be problematic if it tried to add paths for autoloaded files.

Also, my apologies that this commit has an old parent (it's whatever rvm was using).

Thanks for your consideration,

Andrew