Skip to content

Commit 8a7e30f

Browse files
committed
Consider .class a source extension during search
The logic here was ported from CRuby, which only considers .rb to be a source extension. This causes our logic to think a filename like "foo.class" is not a source file and try to load it as either "foo.class.rb" or "foo.class.class". This is the cause of jruby#8758 and prevents explicitly loading precompiled Ruby sources using the filename with .class extension. The fix here modifies the source extension check to also consider other configured source extensions, so that when .class searching is enabled, we will properly treat `require "foo.class"` as a source file. Fixes jruby#8758
1 parent 8579650 commit 8a7e30f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/main/java/org/jruby/runtime/load/LibrarySearcher.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,12 @@ public static SuffixType getSuffixTypeForLoad(final String[] fileHolder) {
250250
}
251251

252252
public static boolean isSourceExt(String file) {
253-
return file.endsWith(".rb");
253+
for (Suffix suffix : Suffix.SOURCES) {
254+
if (file.endsWith(suffix.extension)) {
255+
return true;
256+
}
257+
}
258+
return false;
254259
}
255260

256261
public static boolean isLibraryExt(String file) {

0 commit comments

Comments
 (0)