protected static class AbstractClassGenerator.ClassLoaderData
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.ref.WeakReference<java.lang.ClassLoader> |
classLoader
Note: ClassLoaderData object is stored as a value of
WeakHashMap<ClassLoader, ...> thus
this classLoader reference should be weak otherwise it would make classLoader strongly reachable
and alive forever. |
private <any> |
generatedClasses
AbstractClassGenerator here holds "cache key" (e.g. |
private static <any> |
GET_KEY |
private java.util.Set<java.lang.String> |
reservedClassNames |
private Predicate |
uniqueNamePredicate |
Constructor and Description |
---|
ClassLoaderData(java.lang.ClassLoader classLoader) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(AbstractClassGenerator gen,
boolean useCache) |
java.lang.ClassLoader |
getClassLoader() |
Predicate |
getUniqueNamePredicate() |
void |
reserveName(java.lang.String name) |
private final java.util.Set<java.lang.String> reservedClassNames
private final <any> generatedClasses
AbstractClassGenerator
here holds "cache key" (e.g. Enhancer
configuration), and the value is the generated class plus some additional values
(see AbstractClassGenerator.unwrapCachedValue(Object)
.
The generated classes can be reused as long as their classloader is reachable.
Note: the only way to access a class is to find it through generatedClasses cache, thus the key should not expire as long as the class itself is alive (its classloader is alive).
private final java.lang.ref.WeakReference<java.lang.ClassLoader> classLoader
WeakHashMap<ClassLoader, ...>
thus
this classLoader reference should be weak otherwise it would make classLoader strongly reachable
and alive forever.
Reference queue is not required since the cleanup is handled by WeakHashMap
.private final Predicate uniqueNamePredicate
private static final <any> GET_KEY
public java.lang.ClassLoader getClassLoader()
public void reserveName(java.lang.String name)
public Predicate getUniqueNamePredicate()
public java.lang.Object get(AbstractClassGenerator gen, boolean useCache)