createInstancesOfClassesImplementing

fun <T : Any> createInstancesOfClassesImplementing(classloader: ClassLoader, clazz: Class<T>, classVersionRange: IntRange? = null): Set<T>

Creates instances of all the classes in the classpath of the provided classloader, which implement the interface of the provided class.

Return

instances of the identified classes.

Parameters

classloader

the classloader, which will be searched for the classes.

clazz

the class of the interface, which the classes - to be returned - must implement.

classVersionRange

if specified an exception is raised if class version is not within the passed range.

Throws

if the classes found do not have proper constructors.

if the class version is not within range.

Note: In order to be instantiated, the associated classes must:

  • be non-abstract

  • either be a Kotlin object or have a constructor with no parameters (or only optional ones)