Top Description Fields Constructors Methods
org.jruby.runtime.load

public Class ClassExtensionLibrary

extends Object
implements Library
Class Inheritance
All Implemented Interfaces
org.jruby.runtime.load.Library
Imports
org.jruby.Ruby, java.net.URL

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

Modifier and TypeField and Description
private final String
private final Class<T>

Constructor Summary

AccessConstructor and Description
public
ClassExtensionLibrary(String name, Class<T> extension)

Method Summary

Modifier and TypeMethod and Description
private static void
buildClassName(StringBuilder nameBuilder, StringBuilder fileBuilder, String[] all, int i, CharSequence serviceName)

private static CharSequence
buildServiceName(final String jarName)

public static int
public String
private static boolean
public void
load(Ruby runtime, boolean wrap)

Implements org.jruby.runtime.load.Library.load.

pack-priv static ClassExtensionLibrary

Returns:

a ClassExtensionLibrary that will boot the ext, or null if none was found
tryFind
(Ruby
the current JRuby runtime
runtime
,
String
the name passed to `require`
searchName
)

Try to locate an extension service in the current classloader resources.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameback to summary
private final String name
theClassback to summary
private final Class<T> theClass

Constructor Detail

ClassExtensionLibraryback to summary
public ClassExtensionLibrary(String name, Class<T> extension)

Method Detail

buildClassNameback to summary
private static void buildClassName(StringBuilder nameBuilder, StringBuilder fileBuilder, String[] all, int i, CharSequence serviceName)
buildServiceNameback to summary
private static CharSequence buildServiceName(final String jarName)
findLeftmostIdentifierback to summary
public static int findLeftmostIdentifier(String[] all)
getNameback to summary
public String getName()
isJavaIdentifierback to summary
private static boolean isJavaIdentifier(String str)
loadback to summary
public void load(Ruby runtime, boolean wrap)

Implements org.jruby.runtime.load.Library.load.

tryFindback to summary
pack-priv static ClassExtensionLibrary tryFind(Ruby runtime, String searchName)

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:Ruby

the current JRuby runtime

searchName:String

the name passed to `require`

Returns:ClassExtensionLibrary

a ClassExtensionLibrary that will boot the ext, or null if none was found