I think this has come around a few times with Monkeybars apps for some
of our users. The workaround for it is pretty easy, but I think some
greater separation between Java and Ruby is better here. It could also
help the developer in thinking that $LOAD_PATH != $CLASSPATH, which is
a somewhat related gotcha.

I think your idea for require for Ruby only (plus jars) and
import_java for Java only is a good idea.

On Feb 16, 2009, at 7:38 PM, Charles Oliver Nutter wrote:

I'm working on http://jira.codehaus.org/browse/JRUBY-3214 and I think we need to ratchet down what load and require do when loading .class files. They've started to get overloaded for loading an individual Java class, which was never the intended purpose. This generally circumvents normal Java classloading and classpath and usually causes things to break, since you can easily load in a single class but fail to load its dependencies.

So I propose the following:

load and require shall only be used for loading .jar files (as an analog to extensions), .rb files, or .class files that represent compiled .rb files.

The problem in the bug is that it tries first to do a normal class load, which sees the current directory's "baz" class and loads it before the "baz.class" in ../foo. When normal Java classloading is taken out of the equation, it works correctly.

This also will affect classloading somewhat; since a given classloader can only load a given package + class once, and with Ruby load paths there could potentially be multiple compiled .rb files with the same Java package and class, each precompiled .rb file will be loaded in its own child classloader and executed.

Those of you with precompiled code will probably want to respond on this thread. I'm going to commit a version of this to trunk that you should be able to try out. In general I don't expect it will affect you if your requires are only ever used to load .jar extensions or .rb/.class Ruby scripts.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email



Reply via email to