On Tue, Feb 17, 2009 at 12:31 AM, Charles Oliver Nutter <[email protected]> wrote: > Stephen Bannasch wrote: >> >> At 8:38 PM -0600 2/16/09, 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. >> >> Are you proposing any changes to how require operates when loading a jar >> that implements BasicLibraryService.basicLoad? >> >> This service is normally used to add Ruby modules and classes. This >> technique is used in the java/jruby versions of RubyGems like hpricot and >> redcloth. > > No, this would remain the same. The only behavior that would change is > using: > > require 'some.java.Class' > > as a way of getting that class loaded and callable. It will now raise an > error saying you should use 'java_import' to load it in (I could have said > "import" but "java_import" is probably more likely to work in all cases, > since rake defines an import method and a few people have run into issues > with that). > > e.g. > > $ jruby -rjava -e "load 'build/classes/jruby/org/jruby/RubyString.class'" > -e:1:in `load': use `java_import' to load normal Java classes (LoadError) > from -e:1
+1 I am sure someone has tried using it, but for it to still be working for them they ended up solving the class loading using a different way. -Tom -- Blog: http://www.bloglines.com/blog/ThomasEEnebo Email: [email protected] , [email protected] --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
