Skip to content

removing LoadService#findLibraryWithClassloaders #1957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 27 commits into from

Conversation

mkristian
Copy link
Member

the main idea is to reuse the current LibrarySearcher.

loading the kernel can be achieved by adding the root of the main classloader (the one which contains jruby-stdlib + jruby-core) to the LOAD_PATH

to expose ruby scripts inside required jar-files they just gets added to LOAD_PATH as well, using the jar:file: protocol

there are still some loose ends, also see travis:

  • the old osgi support seems to work even less now
  • gems from jars which are added to the classpath/classloader via java features (not via required 'my.jar') can not be found and/or do not work when they use something like Dir[ 'asd/*' ]
  • some LOAD_PATH issue for 1.9 mode
  • some loading issues with ruby scripts from jars or nested jars (ant test-extended)
  • Gems in a jar can't be required from code #1812 shows an inconsistency regarding requiring a jar with embedded gems.
    • adding it to the classpath on the cmd-line works
    • requiring it with -rmy.jar on the cmd-line works
    • require 'my.jar' does not work

my thoughts about requiring jars and "adding them to the LOAD_PATH":

  • a gem with java extension does not need this feature
  • a java application using ruby scripting will add those jars with ruby files in the java way: as part of the classpath/classloader
  • a project managed by bundler/jbundler will not need these or can easily avoid
  • looking at jbundler where it is easy to have a bigger number of jars required which unnecessary bloats up the load_path and especially with using JarResource and its caching.

it would be nice if all those features would work the same for all the different environments:

  • commandline
  • jruby-complete
  • j2ee
  • osgi
  • ....
    but testing them only for the "commandline" case is not enough and nesting jars inside jars inside jars is problematic with more complex java frameworks.

@mkristian mkristian force-pushed the test-load-from-jruby-classloader branch 5 times, most recently from 0e7925f to 4f28d3c Compare September 13, 2014 21:33
@mkristian mkristian force-pushed the test-load-from-jruby-classloader branch from 9214912 to 3c40d9a Compare September 25, 2014 15:41
… handle

those jar (and its ruby script content) explicitly with the JRubyClassloaderResource

each required jar will be add to LOAD_PATH using jar:file: protocol URIs. with
this all Dir glob, etc will work on those jars and its embedded ruby scripts.
…ttached "jars" can be found via

the Thread.currentThread.contextClassLoader which means all ruby scripts will be found through this pass.
running jruby from other environments like servlets just leave the context classloader as parent.

Dir-glob does not work in general with the Thread.currentThread.contextClassLoader and this would also
shadow the LoadPath entries for the attached jars since the context-classloader gets inspect first

finally it keeps the classloader semantic uniform wether executed from commandline or inside a j2ee container
or osgi framework
…o avoid finding

it on the classpath and loadpath
* add property/config to switch back to legacy loading
* use uri:classloader: protocol for setting jruby.home
* give preference to RubyInstanceConfig.class.getClassLoader instead of Thread.currentThread.contextClassLoader
* do not assume URL.openstream is NOT null - happens with knoplerfish-osgi framework
@mkristian mkristian closed this Dec 6, 2014
@mkristian mkristian deleted the test-load-from-jruby-classloader branch December 6, 2014 12:06
@headius headius modified the milestone: Invalid or Duplicate May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants