Package org.jruby.runtime.load
Class ClassExtensionLibrary
java.lang.Object
org.jruby.runtime.load.ClassExtensionLibrary
- All Implemented Interfaces:
Library
The ClassExtensionLibrary wraps a class which implements BasicLibraryService,
and when asked to load the service, does a basicLoad of the BasicLibraryService.
When the time comes to add other loading mechanisms for loading a class, this
is the place where they will be added. The load method will check interface
you can load a class with, and do the right thing.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidbuildClassName(StringBuilder nameBuilder, StringBuilder fileBuilder, String[] all, int i, CharSequence serviceName) private static CharSequencebuildServiceName(String jarName) static intfindLeftmostIdentifier(String[] all) getName()private static booleanisJavaIdentifier(String str) void(package private) static ClassExtensionLibraryTry to locate an extension service in the current classloader resources.
-
Field Details
-
theClass
-
name
-
-
Constructor Details
-
ClassExtensionLibrary
-
-
Method Details
-
tryFind
Try to locate an extension service in the current classloader resources. This happens after the jar has been added to JRuby's URLClassLoader (JRubyClassLoader) and is how extensions can magically load. The basic logic is to use the require name (@param searchName) to build the name of a class ending in "Service", and then invoke that class to boot the extension. The looping logic here was in response to a RubyGems change that started absolutizing the path to the extension jar under some circumstances, leading to an incorrect package/class name for the service contained therein. The new logic will try successively more trailing elements until one of them is not a valid package name or all elements have been exhausted.- Parameters:
runtime- the current JRuby runtimesearchName- the name passed to `require`- Returns:
- a ClassExtensionLibrary that will boot the ext, or null if none was found
-
findLeftmostIdentifier
-
isJavaIdentifier
-
buildClassName
private static void buildClassName(StringBuilder nameBuilder, StringBuilder fileBuilder, String[] all, int i, CharSequence serviceName) -
buildServiceName
-
getName
-
load
-