Skip to content

Commit

Permalink
Fix JRUBY-6731
Browse files Browse the repository at this point in the history
Can't load class files in WARs compiled by warbler using jruby 1.7.0.preview1

When requiring a file with an explicit .class extension, assume
the .class filename is the only filename to be searched.

Because a require of .class almost always will indicate that the
user wants to load a specific precompiled Ruby file, there's no
good reason (I know of) to search for anything else.

The original logic did not work at all; require 'foo.class' would
search for 'foo.class.rb' and 'foo.class.class' (in that order)
but never 'foo.class'.

The claim is that this worked in 1.6.7.2, but I could not
reproduce that with a simple case. The logic involved does not
appear to have changed in a substantial way since well before
1.6.7.2, and in any case I believe the fix here is the right way
for it to work.
  • Loading branch information
headius authored and dekellum committed Aug 3, 2012
1 parent 7c8dba1 commit 86ef07e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/org/jruby/runtime/load/LoadService.java
Expand Up @@ -685,6 +685,10 @@ public void prepareRequireSearch(final String file) {

// trim extension to try other options
searchFile = file.substring(0, matcher.start());
} else if (file.endsWith(".class")) {
// For JRUBY-6731, treat require 'foo.class' as no other filename than 'foo.class'.
suffixType = SuffixType.Neither;
searchFile = file;
} else {
// unknown extension, fall back to search with extensions
suffixType = SuffixType.Both;
Expand Down

0 comments on commit 86ef07e

Please sign in to comment.