Package ghidra.util.classfinder
Class ClassSearcher
java.lang.Object
ghidra.util.classfinder.ClassSearcher
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdd a change listener that will be notified when the classpath is searched for new classes.getClasses(Class<T> c) Getpriority-sortedclasses that implement or derive from the given classgetClasses(Class<T> c, Predicate<Class<? extends T>> classFilter) Getpriority-sortedclasses that implement or derive from the given classstatic <T> List<T>getInstances(Class<T> c) static <T> List<T>getInstances(Class<T> c, ClassFilter filter) Getpriority-sortedclasses instances that implement or derive from the given classstatic voidRemove the change listenerstatic voidsearch(boolean forceRefresh, TaskMonitor monitor) Deprecated, for removal: This API element is subject to removal in a future version.static voidsearch(TaskMonitor monitor) Searches the classpath and updates the list of available classes which satisfy the class filter.
-
Field Details
-
SEARCH_ALL_JARS_PROPERTY
- See Also:
-
-
Method Details
-
getClasses
Getpriority-sortedclasses 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) Getpriority-sortedclasses that implement or derive from the given class- Parameters:
c- the filter classclassFilter- A Predicate that tests class objects (that are already of type T) for further filtering,nullis equivalent to "return true"- Returns:
priority-sortedlist of classes that implement or extend T and pass the filtering test performed by the predicate
-
getInstances
-
getInstances
Getpriority-sortedclasses instances that implement or derive from the given class- Parameters:
c- the filter classfilter- A Predicate that tests class objects (that are already of type T) for further filtering,nullis equivalent to "return true"- Returns:
priority-sortedlist of classes instances that implement or extend T and pass the filtering test performed by the predicate
-
addChangeListener
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
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.usesearch(TaskMonitor)insteadThis deprecated method is now simply a pass-through forsearch(TaskMonitor).- Parameters:
forceRefresh- ignoredmonitor- the task monitor- Throws:
CancelledException- if cancelled
-
search
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
-
search(TaskMonitor)instead