Package ghidra.util.classfinder
Class ClassSearcher
- java.lang.Object
-
- ghidra.util.classfinder.ClassSearcher
-
public class ClassSearcher extends java.lang.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 Summary
Fields Modifier and Type Field Description static java.lang.String
SEARCH_ALL_JARS_PROPERTY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addChangeListener(javax.swing.event.ChangeListener l)
Add a change listener that will be notified when the classpath is searched for new classes.static <T> java.util.Set<java.lang.Class<? extends T>>
getClasses(java.lang.Class<T> c)
Get classes that implement or derive from the given classstatic <T> java.util.Set<java.lang.Class<? extends T>>
getClasses(java.lang.Class<T> c, java.util.function.Predicate<java.lang.Class<? extends T>> classFilter)
Get classes that implement or derive from the given classstatic <T> java.util.Set<T>
getInstances(java.lang.Class<T> c)
static <T> java.util.Set<T>
getInstances(java.lang.Class<T> c, ClassFilter filter)
static void
removeChangeListener(javax.swing.event.ChangeListener l)
Remove the change listenerstatic void
search(boolean forceRefresh, TaskMonitor monitor)
Searches the classpath and updates the list of available classes which satisfy the class filter.
-
-
-
Field Detail
-
SEARCH_ALL_JARS_PROPERTY
public static final java.lang.String SEARCH_ALL_JARS_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getClasses
public static <T> java.util.Set<java.lang.Class<? extends T>> getClasses(java.lang.Class<T> c)
Get classes that implement or derive from the given class- Parameters:
c
- class filter class- Returns:
- set of classes that implement or extend T
-
getClasses
public static <T> java.util.Set<java.lang.Class<? extends T>> getClasses(java.lang.Class<T> c, java.util.function.Predicate<java.lang.Class<? extends T>> classFilter)
Get classes that implement or derive from the given class- Parameters:
c
- class filter classclassFilter
- A Predicate that tests class objects (that are already of type T) for further filtering,null
is equivalent to "return true"- Returns:
- set of classes that implement or extend T and pass the filtering test performed by the predicate.
-
getInstances
public static <T> java.util.Set<T> getInstances(java.lang.Class<T> c)
-
getInstances
public static <T> java.util.Set<T> getInstances(java.lang.Class<T> c, ClassFilter filter)
-
addChangeListener
public static void addChangeListener(javax.swing.event.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(javax.swing.event.ChangeListener l)
Remove the change listener- Parameters:
l
- the listener to remove
-
search
public static void search(boolean forceRefresh, 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:
forceRefresh
- if true the class cache is ignored and the search is performed from scratch.monitor
- the progress monitor for the search.- Throws:
CancelledException
- if the operation is cancelled
-
-