Skip to content

Commit

Permalink
Fix JRuby ext loading to report better errors (where it reported none…
Browse files Browse the repository at this point in the history
… before).

(cherry picked from commit 68976c3)
  • Loading branch information
headius committed Sep 13, 2011
1 parent 33711f6 commit e17cdf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/org/jruby/javasupport/JavaSupport.java
Expand Up @@ -129,7 +129,7 @@ public void setActive(boolean active) {
this.active = active;
}

private Class loadJavaClass(String className) throws ClassNotFoundException {
public Class loadJavaClass(String className) throws ClassNotFoundException {
Class primitiveClass;
if ((primitiveClass = PRIMITIVE_CLASSES.get(className)) == null) {
if (!Ruby.isSecurityRestricted()) {
Expand Down
17 changes: 13 additions & 4 deletions src/org/jruby/runtime/load/LoadService.java
Expand Up @@ -613,11 +613,20 @@ public boolean trySearch(SearchState state) {
}

// quietly try to load the class
Class theClass = runtime.getJavaSupport().loadJavaClassQuiet(className);
Class theClass = runtime.getJavaSupport().loadJavaClass(className);
state.library = new ClassExtensionLibrary(className + ".java", theClass);
} catch (Exception ee) {
state.library = null;
runtime.getGlobalVariables().clear("$!");
} catch (ClassNotFoundException cnfe) {
if (runtime.isDebug()) cnfe.printStackTrace();
// we ignore this and assume the jar is not an extension
} catch (UnsupportedClassVersionError ucve) {
if (runtime.isDebug()) ucve.printStackTrace();
throw runtime.newLoadError("JRuby ext built for wrong Java version in `" + finName + "': " + ucve);
} catch (IOException ioe) {
if (runtime.isDebug()) ioe.printStackTrace();
throw runtime.newLoadError("IOException loading extension `" + finName + "`: " + ioe);
} catch (Exception e) {
if (runtime.isDebug()) e.printStackTrace();
throw runtime.newLoadError("Exception loading extension `" + finName + "`: " + e);
}

// If there was a good library before, we go back to that
Expand Down

0 comments on commit e17cdf7

Please sign in to comment.