jruby/jruby — pull request #281 by dontfidget (2012-09-04 00:05:47+00:00)
Title: call Kernel.require ruby method from autoload callback instead of callin...

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. I assume it rubygems is the most well-known overrider of Kernel.require. It presumably 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.

Thanks for your consideration,

Andrew