public final class MadkitClassLoader extends URLClassLoader
Modifier and Type | Method and Description |
---|---|
static String |
findJavaExecutable(String executable)
Find a JDK/JRE program
|
static Set<String> |
getAgentsWithMain() |
static Set<String> |
getAllAgentClasses()
Returns the names of all the available agent classes
|
static Set<MASModel> |
getAvailableConfigurations()
Returns all the session configurations available on the class path
|
static String |
getClassPackageName(String classFullName)
Returns the package name for this class name.
|
static String |
getClassSimpleName(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 Set<String> |
getMDKFiles()
Returns the names of all the mdk properties files available
|
static Set<String> |
getXMLConfigurations()
Returns the names of all the xml configuration files available
|
protected Class<?> |
loadClass(String name,
boolean resolve) |
static boolean |
loadJarsFromDirectory(String directoryPath)
Loads all the jars present in a directory
|
static boolean |
loadUrl(URL url)
Adds a directory or a jar file to the class path.
|
static void |
main(String[] args)
This is only used by ant scripts for building MDK jar files.
|
static void |
reloadClass(String name)
Schedule the reloading of the byte code of a class
for its next loading.
|
String |
toString() |
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
defineClass, defineClass
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 Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
ClassNotFoundException
public static void reloadClass(String name) throws 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 classClassNotFoundException
- if the class cannot be found on the class pathpublic static boolean loadJarsFromDirectory(String directoryPath)
directoryPath
- directory's pathtrue
if at least one new jar has been loadedpublic static String getClassPackageName(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 String getClassSimpleName(String classFullName)
java.lang.Object
as input gives Object
as output.classFullName
- the full name of a classpublic static boolean loadUrl(URL url)
url
- the resource to addtrue
if this url was not already loadedpublic static Set<MASModel> getAvailableConfigurations()
public static Set<String> getAllAgentClasses()
public static Set<String> getMDKFiles()
public static Set<String> getXMLConfigurations()
public static Set<String> getAgentsWithMain()
main
method.public static String findJavaExecutable(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(String[] args) throws FileNotFoundException, IOException
args
- FileNotFoundException
IOException
Fabien Michel, Olivier Gutknecht, Jacques Ferber - February 12 2016