Skip to content

Instantly share code, notes, and snippets.

Created March 9, 2011 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/863022 to your computer and use it in GitHub Desktop.
Save anonymous/863022 to your computer and use it in GitHub Desktop.
diff --git a/src/org/jruby/runtime/load/LoadService.java b/src/org/jruby/runtime/load/LoadService.java
index b9eb6b9..dffe269 100644
--- a/src/org/jruby/runtime/load/LoadService.java
+++ b/src/org/jruby/runtime/load/LoadService.java
@@ -323,12 +323,6 @@ public class LoadService {
SearchState state;
try {
- // Even if we don't support .so, some stdlib require .so directly.
- // Replace it with .jar to look for a java extension
- // JRUBY-5033: The ExtensionSearcher will locate C exts, too, this way.
- if (file.endsWith(".so")) {
- file = file.replaceAll(".so$", ".jar");
- }
state = findFileForLoad(file);
return tryLoadingLibraryOrScript(runtime, state);
@@ -667,6 +661,22 @@ public class LoadService {
}
}
+ /**
+ * For JRUBY-5569: LoadError when trying to require a .so.rb ruby file
+ *
+ * MRI appears to attempt to add .rb to a native extension filename if that
+ * native extension filename can't be found.
+ */
+ public class ExtensionFailoverSearcher implements LoadSearcher {
+ public boolean shouldTrySearch(SearchState state) {
+ return state.suffixType == SuffixType.Extension;
+ }
+
+ public void trySearch(SearchState state) {
+ state.library = findLibraryWithoutCWD(state, state.loadName, SuffixType.Source);
+ }
+ }
+
public static class SearchState {
public Library library;
public String loadName;
@@ -786,6 +796,7 @@ public class LoadService {
searchers.add(new ClassLoaderSearcher());
searchers.add(new BailoutSearcher());
searchers.add(new ExtensionSearcher());
+ searchers.add(new ExtensionFailoverSearcher());
searchers.add(new ScriptClassSearcher());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment