Class ClassExtensionLibrary

java.lang.Object
org.jruby.runtime.load.ClassExtensionLibrary
All Implemented Interfaces:
Library

public class ClassExtensionLibrary extends Object implements 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 Details

    • theClass

      private final Class theClass
    • name

      private final String name
  • Constructor Details

    • ClassExtensionLibrary

      public ClassExtensionLibrary(String name, Class extension)
  • Method Details

    • tryFind

      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 - the current JRuby runtime
      searchName - the name passed to `require`
      Returns:
      a ClassExtensionLibrary that will boot the ext, or null if none was found
    • findLeftmostIdentifier

      public static int findLeftmostIdentifier(String[] all)
    • isJavaIdentifier

      private static boolean isJavaIdentifier(String str)
    • buildClassName

      private static void buildClassName(StringBuilder nameBuilder, StringBuilder fileBuilder, String[] all, int i, CharSequence serviceName)
    • buildServiceName

      private static CharSequence buildServiceName(String jarName)
    • getName

      public String getName()
    • load

      public void load(Ruby runtime, boolean wrap)
      Specified by:
      load in interface Library