Skip to content

RubyGems 2.4.5 Upgrade Triggers Bug in Java Extension Loading #2336

Description

@bbrowning

RubyGems 2.4.5 has some new logic that sometimes (but not always - depends on what's already loaded or not) expands require statements to absolute paths before passing them on to the original require.

Depending on the state of things, it's possible for a require statement to hit this line of code in RubyGems - https://github.com/rubygems/rubygems/blob/v2.4.5/lib/rubygems/core_ext/kernel_require.rb#L69. That code expands the thing being required to an absolute path before handing it off to the original require logic.

So, when a .jar is required via an absolute path, the logic in ClassExtensionLibrary at

Class theClass = runtime.getJavaSupport().loadJavaClass(className);
ends up creating the wrong package name and thus cannot load the *Service class for the Java extension. The searchName string passed to ClassExtensionLibrary's tryFind ends up looking something like "/path/to/nokogiri/nokogiri.jar" and it converts that to the class path.to.nokogiri.NokogiriService, which obviously can't be found.

Here's a gist that demonstrates this problem against JRuby 1.7.18-SNAPSHOT - https://gist.github.com/bbrowning/cda2606bd26683ea4831

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions