public class EmptyClassLoader
extends java.lang.ClassLoader
Modifier and Type | Field and Description |
---|---|
private java.util.WeakHashMap<java.lang.String,java.lang.ref.SoftReference<java.lang.Class<?>>> |
classes
Already loaded classes
|
private java.io.File |
directory
Directory where class are compiled
|
private JHelpJarClassLoader |
jarClassLoader
Base jar class loader
|
private java.util.HashSet<java.lang.String> |
onCreation
On creation class for avoid infinite loop
|
private static int |
tempFileIndex
Next temporary file index
|
Constructor and Description |
---|
EmptyClassLoader(java.util.jar.JarFile... jarsToMock)
Constructs EmptyClassLoader
|
Modifier and Type | Method and Description |
---|---|
private void |
addImport(java.lang.String base,
java.util.HashSet<java.lang.String> set,
java.lang.String name)
Add import in list
|
private void |
appendContent(boolean internal,
java.lang.String decal,
java.lang.String name,
java.lang.StringBuilder stringBuilder,
java.lang.Class<?> classInJar,
java.lang.String simpleName)
Append content of class to current code
|
private void |
appendInternal(java.lang.String decal,
java.lang.StringBuilder stringBuilder,
java.lang.String name)
Append internal class inside a class
|
private void |
compileClass(java.lang.String name,
java.util.HashSet<Compiler.NameCode> needCompile)
Compile a list of class
|
private static java.lang.String |
createFile()
Create temporary file.
|
private void |
fillImports(java.lang.String base,
java.lang.String name,
java.util.HashSet<java.lang.String> imports,
java.lang.Class<?> classInJar)
Fill imports
|
private java.lang.Class<?> |
getAlreadyKnown(java.lang.String name)
Get class if already known
|
private java.lang.String |
getArrayLevel(java.lang.Class<?> claz)
Array level of a class
|
private java.lang.Class<?> |
getRootType(java.lang.Class<?> claz)
Root type of a class
|
protected java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve)
Load a class
|
private java.lang.Class<?> |
loadFromCompiledFile(java.lang.String name,
boolean resolve)
Load class from a already compiled file
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
private static int tempFileIndex
private final java.util.WeakHashMap<java.lang.String,java.lang.ref.SoftReference<java.lang.Class<?>>> classes
private java.io.File directory
private final JHelpJarClassLoader jarClassLoader
private final java.util.HashSet<java.lang.String> onCreation
public EmptyClassLoader(java.util.jar.JarFile... jarsToMock)
jarsToMock
- Jars to see as emptyprivate static java.lang.String createFile()
private void addImport(java.lang.String base, java.util.HashSet<java.lang.String> set, java.lang.String name)
base
- Base class nameset
- List of importname
- Class nameprivate void appendContent(boolean internal, java.lang.String decal, java.lang.String name, java.lang.StringBuilder stringBuilder, java.lang.Class<?> classInJar, java.lang.String simpleName) throws java.lang.ClassNotFoundException
internal
- Indicates if class is internaldecal
- Start of each linename
- Class namestringBuilder
- Where appendclassInJar
- Class to appendsimpleName
- Short name of classjava.lang.ClassNotFoundException
- If class not foundprivate void appendInternal(java.lang.String decal, java.lang.StringBuilder stringBuilder, java.lang.String name) throws java.lang.ClassNotFoundException
decal
- Add start of each linestringBuilder
- Where appendname
- Class namejava.lang.ClassNotFoundException
- If class not foundprivate void compileClass(java.lang.String name, java.util.HashSet<Compiler.NameCode> needCompile) throws java.lang.ClassNotFoundException
name
- Class to compileneedCompile
- Need to compile listjava.lang.ClassNotFoundException
- If class not foundprivate void fillImports(java.lang.String base, java.lang.String name, java.util.HashSet<java.lang.String> imports, java.lang.Class<?> classInJar) throws java.lang.ClassNotFoundException
base
- Base namename
- Class nameimports
- List import to fillclassInJar
- Classjava.lang.ClassNotFoundException
- if class not foundprivate java.lang.Class<?> getAlreadyKnown(java.lang.String name)
name
- Class namenull
private java.lang.String getArrayLevel(java.lang.Class<?> claz)
claz
- Classprivate java.lang.Class<?> getRootType(java.lang.Class<?> claz)
claz
- Classnull
for voidprivate java.lang.Class<?> loadFromCompiledFile(java.lang.String name, boolean resolve)
name
- File nameresolve
- Indicates if need to resolvenull
protected java.lang.Class<?> loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
name
- Class nameresolve
- Indicates if class need to be resolvedjava.lang.ClassNotFoundException
- If class not foundClassLoader.loadClass(java.lang.String, boolean)