public final class TestCaseClassLoader extends ClassLoader
The list of excluded package paths
is either hardcoded in defaultExclusions,
specified as property with key PROP_KEY_NO_CLS_RELOAD.
in a properties file EXCLUDED_FILE
that is located in the same place as the TestCaseClassLoader class.
Known limitation:
| Modifier and Type | Field and Description |
|---|---|
private String[] |
defaultExclusions
Default excluded paths.
|
private List<String> |
excluded
Holds the excluded paths.
|
(package private) static String |
EXCLUDED_FILE
Name of excluded properties file.
|
private JavaPath |
jPath
The scanned class path.
|
private static int |
LEN_CLS_STREAM
The initial length of a stream to read class files from.
|
private static String |
PROP_KEY_NO_CLS_RELOAD
Key of system property
containing a ":"-separated list of packages or classes
to be excluded from reloading.
|
| Modifier | Constructor and Description |
|---|---|
|
TestCaseClassLoader()
Constructs a TestCaseLoader.
|
private |
TestCaseClassLoader(String classPath)
Constructs a TestCaseLoader.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) Class<?> |
defineClass(String name) |
URL |
getResource(String name) |
InputStream |
getResourceAsStream(String name) |
private boolean |
isExcluded(String name)
Returns whether the name with the given name
is excluded from being loaded.
|
Class<?> |
loadClass(String name,
boolean resolve) |
private byte[] |
lookupClassData(String className) |
private void |
readExcludedPackages()
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignersprivate static final String PROP_KEY_NO_CLS_RELOAD
excluded.static final String EXCLUDED_FILE
exlude.xxx
and are read in excluded.private static final int LEN_CLS_STREAM
private JavaPath jPath
private List<String> excluded
readExcludedPackages()
and used by isExcluded(java.lang.String).private final String[] defaultExclusions
isExcluded(java.lang.String)public TestCaseClassLoader()
private TestCaseClassLoader(String classPath)
classPath - the classpath.public URL getResource(String name)
getResource in class ClassLoaderpublic InputStream getResourceAsStream(String name)
getResourceAsStream in class ClassLoaderprivate boolean isExcluded(String name)
name - the fully qualified name of a class as a String.boolean which shows whether name
starts with one of the prefixes given by excluded.
In this case the corresponding class is not loaded.Class<?> defineClass(String name) throws ClassNotFoundException
ClassNotFoundExceptionpublic Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass in class ClassLoaderClassNotFoundExceptionprivate byte[] lookupClassData(String className) throws ClassNotFoundException
ClassNotFoundExceptionprivate void readExcludedPackages()
excluded using defaultExclusions,
PROP_KEY_NO_CLS_RELOAD and EXCLUDED_FILE.
defaultExclusions
are added to excluded.
PROP_KEY_NO_CLS_RELOAD is interpreted
as a ":"-seprated list of entries
each of which is added to excluded.
EXCLUDED_FILE is interpreted as filename
and the file is interpreted as Properties File with property keys
starting with excluded.;
all the other properties are ignored.
The values are trimmed
and a trailing * is removed if present.
If the remaining path is nontrivial, it is added to excluded.
Copyright © 2012–2018 Simuline Organization (l2r). All rights reserved.