5.14. Supported Utilities in Extensions
The junit-platform-commons
artifact exposes a package named [org.junit.platform.commons.support](https://junit.org/junit5/docs/current/api/org.junit.platform.commons/org/junit/platform/commons/support/package-summary.html)
that contains maintained utility methods for working with annotations, classes, reflection, and classpath scanning tasks. TestEngine
and Extension
authors are encouraged to use these supported methods in order to align with the behavior of the JUnit Platform.
5.14.1. Annotation Support
AnnotationSupport
provides static utility methods that operate on annotated elements (e.g., packages, annotations, classes, interfaces, constructors, methods, and fields). These include methods to check whether an element is annotated or meta-annotated with a particular annotation, to search for specific annotations, and to find annotated methods and fields in a class or interface. Some of these methods search on implemented interfaces and within class hierarchies to find annotations. Consult the Javadoc for [AnnotationSupport](https://junit.org/junit5/docs/current/api/org.junit.platform.commons/org/junit/platform/commons/support/AnnotationSupport.html)
for further details.
5.14.2. Class Support
ClassSupport
provides static utility methods for working with classes (i.e., instances of java.lang.Class
). Consult the Javadoc for [ClassSupport](https://junit.org/junit5/docs/current/api/org.junit.platform.commons/org/junit/platform/commons/support/ClassSupport.html)
for further details.
5.14.3. Reflection Support
ReflectionSupport
provides static utility methods that augment the standard JDK reflection and class-loading mechanisms. These include methods to scan the classpath in search of classes matching specified predicates, to load and create new instances of a class, and to find and invoke methods. Some of these methods traverse class hierarchies to locate matching methods. Consult the Javadoc for [ReflectionSupport](https://junit.org/junit5/docs/current/api/org.junit.platform.commons/org/junit/platform/commons/support/ReflectionSupport.html)
for further details.
5.14.4. Modifier Support
ModifierSupport
provides static utility methods for working with member and class modifiers — for example, to determine if a member is declared as public
, private
, abstract
, static
, etc. Consult the Javadoc for [ModifierSupport](https://junit.org/junit5/docs/current/api/org.junit.platform.commons/org/junit/platform/commons/support/ModifierSupport.html)
for further details.