Skip to content

Commit

Permalink
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@

import org.jruby.Ruby;

import java.net.URL;

/**
* The ClassExtensionLibrary wraps a class which implements BasicLibraryService,
* and when asked to load the service, does a basicLoad of the BasicLibraryService.
@@ -62,10 +64,16 @@ static ClassExtensionLibrary tryFind(Ruby runtime, String searchName) {

// We don't want a package name beginning with dots, so we remove them
String className = finName.toString().replaceAll("^\\.*", "");
String classFile = className.replaceAll("\\.", "/") + ".class";

// quietly try to load the class, which must be reachable as a .class resource
URL resource = runtime.getJRubyClassLoader().getResource(classFile);
if (resource != null) {
Class theClass = runtime.getJavaSupport().loadJavaClass(className);
return new ClassExtensionLibrary(className + ".java", theClass);
}

// quietly try to load the class
Class theClass = runtime.getJavaSupport().loadJavaClass(className);
return new ClassExtensionLibrary(className + ".java", theClass);
return null;
} catch (ClassNotFoundException cnfe) {
if (runtime.isDebug()) cnfe.printStackTrace();

0 comments on commit 35d5d13

Please sign in to comment.