Class ClassSearcher

java.lang.Object
ghidra.util.classfinder.ClassSearcher

public class ClassSearcher extends Object
This class is a collection of static methods used to discover classes that implement a particular interface or extend a particular base class.

Warning: Using the search feature of this class will trigger other classes to be loaded. Thus, clients should not make calls to this class inside of static initializer blocks

Note: if your application is not using a module structure for its release build, then your application must create the following file, with the required entries, in order to find extension points:

        <install dir>/data/ExtensionPoint.manifest
 
  • Field Details

  • Method Details

    • getClasses

      public static <T> List<Class<? extends T>> getClasses(Class<T> c)
      Get priority-sorted classes that implement or derive from the given class
      Parameters:
      c - the filter class
      Returns:
      set of classes that implement or extend T
    • getClasses

      public static <T> List<Class<? extends T>> getClasses(Class<T> c, Predicate<Class<? extends T>> classFilter)
      Get priority-sorted classes that implement or derive from the given class
      Parameters:
      c - the filter class
      classFilter - A Predicate that tests class objects (that are already of type T) for further filtering, null is equivalent to "return true"
      Returns:
      priority-sorted list of classes that implement or extend T and pass the filtering test performed by the predicate
    • getInstances

      public static <T> List<T> getInstances(Class<T> c)
    • getInstances

      public static <T> List<T> getInstances(Class<T> c, ClassFilter filter)
      Get priority-sorted classes instances that implement or derive from the given class
      Parameters:
      c - the filter class
      filter - A Predicate that tests class objects (that are already of type T) for further filtering, null is equivalent to "return true"
      Returns:
      priority-sorted list of classes instances that implement or extend T and pass the filtering test performed by the predicate
    • addChangeListener

      public static void addChangeListener(ChangeListener l)
      Add a change listener that will be notified when the classpath is searched for new classes.

      Note: The listener list is implemented using WeakReferences. Therefore, the caller must maintain a handle to the listener being added, or else it will be garbage collected and never called.

      Parameters:
      l - the listener to add
    • removeChangeListener

      public static void removeChangeListener(ChangeListener l)
      Remove the change listener
      Parameters:
      l - the listener to remove
    • search

      @Deprecated(forRemoval=true, since="10.1") public static void search(boolean forceRefresh, TaskMonitor monitor) throws CancelledException
      Deprecated, for removal: This API element is subject to removal in a future version.
      This deprecated method is now simply a pass-through for search(TaskMonitor).
      Parameters:
      forceRefresh - ignored
      monitor - the task monitor
      Throws:
      CancelledException - if cancelled
    • search

      public static void search(TaskMonitor monitor) throws CancelledException
      Searches the classpath and updates the list of available classes which satisfy the class filter. Classes which data types, and language providers. When the search completes and was not cancelled, the change listeners are notified.
      Parameters:
      monitor - the progress monitor for the search.
      Throws:
      CancelledException - if the operation is cancelled