ClassLoader, name of the generated class, and transformations
applied before generation.
| Modifier and Type | Class and Description |
|---|---|
| protected static class | |
| protected static class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private static volatile Map | |
| private ClassLoader | |
| private String | |
| private Class | |
| private static final ThreadLocal | |
| private static final boolean | |
| private static final boolean | |
| private Object | |
| private String | |
| private NamingPolicy | |
| private AbstractClassGenerator. | |
| private GeneratorStrategy | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected Object | |
| protected abstract Object | |
| protected Class | |
| private String | |
| public boolean | |
| public ClassLoader | |
| protected final String | |
| public static AbstractClassGenerator | |
| protected abstract ClassLoader | |
| public NamingPolicy | |
| protected ProtectionDomain | Returns: the protection domain (null for using a default)Returns the protection domain to use when defining the class. |
| public GeneratorStrategy | |
| public boolean | |
| protected abstract Object | |
| public void | setAttemptLoad(boolean attemptLoad)
If set, CGLIB will attempt to load classes from the specified
|
| public void | setClassLoader(ClassLoader
the loader to generate the new class with, or null to use the default classLoader)Set the |
| private void | |
| public void | |
| protected void | |
| public void | setNamingPolicy(NamingPolicy
the custom policy, or null to use the default namingPolicy)Override the default naming policy. |
| public void | setStrategy(GeneratorStrategy strategy)
Set the strategy to use to create the bytecode from this generator. |
| public void | setUseCache(boolean useCache)
Whether use and update the static cache of generated classes for a class with the same properties. |
| protected Object | |
| protected T |
| attemptLoad | back to summary |
|---|---|
| private boolean attemptLoad | |
| CACHE | back to summary |
|---|---|
| private static volatile Map<ClassLoader, AbstractClassGenerator. | |
| classLoader | back to summary |
|---|---|
| private ClassLoader classLoader | |
| className | back to summary |
|---|---|
| private String className | |
| contextClass | back to summary |
|---|---|
| private Class<T> contextClass | |
| CURRENT | back to summary |
|---|---|
| private static final ThreadLocal<T> CURRENT | |
| DEFAULT_USE_CACHE | back to summary |
|---|---|
| private static final boolean DEFAULT_USE_CACHE | |
| inNativeImage | back to summary |
|---|---|
| private static final boolean inNativeImage | |
| key | back to summary |
|---|---|
| private Object key | |
| namePrefix | back to summary |
|---|---|
| private String namePrefix | |
| namingPolicy | back to summary |
|---|---|
| private NamingPolicy namingPolicy | |
| source | back to summary |
|---|---|
| private AbstractClassGenerator. | |
| strategy | back to summary |
|---|---|
| private GeneratorStrategy strategy | |
| useCache | back to summary |
|---|---|
| private boolean useCache | |
| AbstractClassGenerator | back to summary |
|---|---|
| protected AbstractClassGenerator(AbstractClassGenerator. | |
| create | back to summary |
|---|---|
| protected Object create(Object key) | |
| firstInstance | back to summary |
|---|---|
| protected abstract Object firstInstance(Class<T> type) throws Exception | |
| generate | back to summary |
|---|---|
| protected Class | |
| generateClassName | back to summary |
|---|---|
| private String generateClassName(Predicate nameTestPredicate) | |
| getAttemptLoad | back to summary |
|---|---|
| public boolean getAttemptLoad() | |
| getClassLoader | back to summary |
|---|---|
| public ClassLoader getClassLoader() | |
| getClassName | back to summary |
|---|---|
| protected final String getClassName() | |
| getCurrent | back to summary |
|---|---|
| public static AbstractClassGenerator Used internally by CGLIB. Returns the | |
| getDefaultClassLoader | back to summary |
|---|---|
| protected abstract ClassLoader getDefaultClassLoader() | |
| getNamingPolicy | back to summary |
|---|---|
public NamingPolicy getNamingPolicy()
| |
| getProtectionDomain | back to summary |
|---|---|
| protected ProtectionDomain getProtectionDomain() Returns the protection domain to use when defining the class.
Default implementation returns
| |
| getStrategy | back to summary |
|---|---|
public GeneratorStrategy getStrategy()
| |
| getUseCache | back to summary |
|---|---|
public boolean getUseCache()
| |
| nextInstance | back to summary |
|---|---|
| protected abstract Object nextInstance(Object instance) throws Exception | |
| setAttemptLoad | back to summary |
|---|---|
| public void setAttemptLoad(boolean attemptLoad) If set, CGLIB will attempt to load classes from the specified
| |
| setClassLoader | back to summary |
|---|---|
| public void setClassLoader(ClassLoader classLoader) Set the
Classes are cached per-
| |
| setClassName | back to summary |
|---|---|
| private void setClassName(String className) | |
| setContextClass | back to summary |
|---|---|
| public void setContextClass(Class<T> contextClass) | |
| setNamePrefix | back to summary |
|---|---|
| protected void setNamePrefix(String namePrefix) | |
| setNamingPolicy | back to summary |
|---|---|
| public void setNamingPolicy(NamingPolicy namingPolicy) Override the default naming policy.
| |
| setStrategy | back to summary |
|---|---|
| public void setStrategy(GeneratorStrategy strategy) Set the strategy to use to create the bytecode from this generator.
By default an instance of | |
| setUseCache | back to summary |
|---|---|
| public void setUseCache(boolean useCache) Whether use and update the static cache of generated classes
for a class with the same properties. Default is | |
| unwrapCachedValue | back to summary |
|---|---|
| protected Object unwrapCachedValue(T cached) | |
| wrapCachedClass | back to summary |
|---|---|
| protected T wrapCachedClass(Class<T> klass) | |
| Modifier and Type | Field and Description |
|---|---|
| private final WeakReference | classLoader
Note ClassLoaderData object is stored as a value of |
| private final LoadingCache | generatedClasses
|
| private static final Function | |
| private final Set | |
| private final Predicate |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Object | |
| public ClassLoader | |
| public Predicate | |
| public void |
| classLoader | back to summary |
|---|---|
| private final WeakReference<ClassLoader> classLoader Note ClassLoaderData object is stored as a value of | |
| generatedClasses | back to summary |
|---|---|
| private final LoadingCache<AbstractClassGenerator<T>, Object, Object> generatedClasses
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). | |
| GET_KEY | back to summary |
|---|---|
| private static final Function<AbstractClassGenerator<T>, Object> GET_KEY | |
| reservedClassNames | back to summary |
|---|---|
| private final Set<String> reservedClassNames | |
| uniqueNamePredicate | back to summary |
|---|---|
| private final Predicate uniqueNamePredicate | |
| ClassLoaderData | back to summary |
|---|---|
| public ClassLoaderData(ClassLoader classLoader) | |
| get | back to summary |
|---|---|
| public Object get(AbstractClassGenerator<T> gen, boolean useCache) | |
| getClassLoader | back to summary |
|---|---|
| public ClassLoader getClassLoader() | |
| getUniqueNamePredicate | back to summary |
|---|---|
| public Predicate getUniqueNamePredicate() | |
| reserveName | back to summary |
|---|---|
| public void reserveName(String name) | |
| name | back to summary |
|---|---|
| pack-priv String name | |
| Source | back to summary |
|---|---|
| public Source(String name) | |