DynamicJarClassLoader

Utility for dynamically loading and instantiating classes from JAR files. The parent loader for the underlying loader will be the class loader that loaded this class. Class loading does not occur until the first call to load a class.

If a JAR file does not exist on one of the paths then an IllegalArgumentException will occur. An IOException will occur if a referenced file is not a valid JAR file.

This class should be referenced with the "use" functionality of Kotlin to ensure that the underlying loader mechanism is closed, or the close() function should be used.

Parameters

jarPaths

a list of paths that reference valid JAR files. The list must not be empty.

Constructors

Link copied to clipboard
constructor(jarPaths: List<Path>)
constructor(jarPath: Path)

Constructor for a single JAR file

constructor(jarPath: String)

Constructor for a single JAR file

constructor(vararg jarPaths: Path)

Constructor for multiple JAR files using vararg

constructor(vararg jarPaths: String)

Constructor for multiple JAR files using vararg

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The class names found within the JAR files. These names are determined directly from the JAR files. No loading of classes occurs to determine the names.

Link copied to clipboard
Link copied to clipboard

The list of URL representations for the JAR files

Functions

Link copied to clipboard
open override fun close()

Close the class loader

Link copied to clipboard
fun declaredPublicNonStaticFunction(loadedClass: Class<*>, functionName: String): KFunction<*>?
fun declaredPublicNonStaticFunction(className: String, functionName: String): KFunction<*>?

Retrieves the public non-static (instance) function of the supplied class name based on the supplied function name.

Link copied to clipboard

Retrieves the public non-static (instance) functions of the supplied class.

Link copied to clipboard
fun declaredPublicStaticFunction(loadedClass: Class<*>, functionName: String): KFunction<*>?
fun declaredPublicStaticFunction(className: String, functionName: String): KFunction<*>?

Retrieves the public static function of the supplied class name based on the supplied function name.

Link copied to clipboard

Retrieves the public static functions of the supplied class name.

Link copied to clipboard
fun findSubClasses(superClass: Class<*>): Map<String, Class<*>>
Link copied to clipboard

Get the list of loaded JAR paths as a list of strings

Link copied to clipboard
fun loadClass(className: String): Class<*>

Load a class by its fully qualified name. The name must be a valid class name within the supporting JAR files.

Link copied to clipboard
fun noArgumentConstructor(loadedClass: Class<*>): KFunction<*>?

Retrieves the no argument constructor of the supplied class or null if one does not exist or is inaccessible.

Retrieves the no argument constructor of the supplied class name or null if one does not exist or is inaccessible.

Link copied to clipboard
fun noArgumentInstance(loadedClass: Class<*>): Any?

Creates an instance of the class via its no argument constructor.

fun noArgumentInstance(className: String): Any?

Creates an instance of the class using its no argument constructor.

Link copied to clipboard
fun publicConstructors(loadedClass: Class<*>): List<KFunction<*>>

Retrieves the public constructors of the supplied java class

Retrieves the public constructors of the supplied class name.

Link copied to clipboard
fun singletonObjectReference(loadedClass: Class<*>): Any?
fun singletonObjectReference(singletonName: String): Any?

A Kotlin object declaration defines a (static) singleton object within the underlying synthetic class defined with a class name the same as the name of the object. This function returns the associated object reference as an Any reference or null.

Link copied to clipboard
open override fun toString(): String