public final class MadkitClassLoader
extends java.net.URLClassLoader
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
findJavaExecutable(java.lang.String executable)
Find a JDK/JRE program
|
static java.util.Set<java.lang.String> |
getAgentsWithMain() |
static java.util.Set<java.lang.String> |
getAllAgentClasses()
Returns the names of all the available agent classes
|
static java.util.Set<MASModel> |
getAvailableConfigurations()
Returns all the session configurations available on the class path
|
static java.lang.String |
getClassPackageName(java.lang.String classFullName)
Returns the package name for this class name.
|
static java.lang.String |
getClassSimpleName(java.lang.String classFullName)
Returns the simple name for a full class name.
|
static MadkitClassLoader |
getLoader()
Returns the last class loader, thus having all the loaded jars on the classpath.
|
static java.util.Set<java.lang.String> |
getMDKFiles()
Returns the names of all the mdk properties files available
|
static java.util.Set<java.lang.String> |
getXMLConfigurations()
Returns the names of all the xml configuration files available
|
protected java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve) |
static boolean |
loadJarsFromDirectory(java.lang.String directoryPath)
Loads all jar files from a directory
|
static boolean |
loadUrl(java.net.URL url)
Adds a directory or a jar file to the class path.
|
static void |
main(java.lang.String[] args)
This is only used by ant scripts for building MDK jar files.
|
static void |
reloadClass(java.lang.String name)
Schedule the reloading of the byte code of a class for its next loading.
|
java.lang.String |
toString() |
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public static MadkitClassLoader getLoader()
protected java.lang.Class<?> loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
public static void reloadClass(java.lang.String name) throws java.lang.ClassNotFoundException
Class.newInstance()
on a class object obtained with ClassLoader.loadClass(String)
, will reflect compilation
changes during run time. In fact, using ClassLoader.loadClass(String)
on the current MDK class loader obtained with
getLoader()
returns the class object corresponding to the last compilation of the java code available on the
class path. Especially, this may return a different version than Class.forName(String)
because
Class.forName(String)
uses the ClassLoader
of the caller's current class which could be different
than the current one (i.e. the one obtained getLoader()
) if several reloads have been done. Especially,
AbstractAgent.launchAgent(String, int, boolean)
always uses the newest version of an agent class.name
- The fully qualified class name of the classjava.lang.ClassNotFoundException
- if the class cannot be found on the class pathpublic static boolean loadJarsFromDirectory(java.lang.String directoryPath)
directoryPath
- directory's pathtrue
if at least one new jar has been loadedpublic static java.lang.String getClassPackageName(java.lang.String classFullName)
java.lang.Object
as input gives
java.lang
as output.classFullName
- the full name of a classnull
if no package is definedpublic static java.lang.String getClassSimpleName(java.lang.String classFullName)
java.lang.Object
as input gives Object
as output.classFullName
- the full name of a classpublic static boolean loadUrl(java.net.URL url)
url
- the resource to addtrue
if this url was not already loadedpublic static java.util.Set<MASModel> getAvailableConfigurations()
public static java.util.Set<java.lang.String> getAllAgentClasses()
public static java.util.Set<java.lang.String> getMDKFiles()
public static java.util.Set<java.lang.String> getXMLConfigurations()
public static java.util.Set<java.lang.String> getAgentsWithMain()
main
method.public static java.lang.String findJavaExecutable(java.lang.String executable)
executable
- the name of the Java program to look for. E.g. "jarsigner", without file extension.null
if not found.public static void main(java.lang.String[] args) throws java.io.FileNotFoundException, java.io.IOException
args
- java.io.FileNotFoundException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
Fabien Michel, Olivier Gutknecht, Jacques Ferber - September 9 2019