findSubclasses

fun findSubclasses(jarFilePath: Path, parentClass: Class<*>, parent: ClassLoader = Thread.currentThread().contextClassLoader): List<String>(source)

Lists all classes and subclasses in a JAR file for a given parent class using Kotlin reflection

Return

Set of class names that extend or implement the parent class

Parameters

jarFilePath

Path to the JAR file

parentClass

The parent KClass to search for subclasses

parent

parent classloader for delegation; must resolve parentClass and its transitive dependencies. Defaults to the calling thread's context classloader — pass an explicit loader (e.g. the one that holds parentClass) when the caller may run on a thread whose context loader does not see those types, otherwise linking a candidate throws NoClassDefFoundError.