Package javassist.scopedpool
Class ScopedClassPool
- java.lang.Object
-
- javassist.ClassPool
-
- javassist.scopedpool.ScopedClassPool
-
public class ScopedClassPool extends ClassPool
A scoped class pool.- Version:
- $Revision: 1.8 $
- Author:
- Bill Burke, Adrian Brock, Kabir Khan
-
-
Field Summary
Fields Modifier and Type Field Description protected Reference<ClassLoader>
classLoader
protected LoaderClassPath
classPath
protected ScopedClassPoolRepository
repository
protected Map<String,CtClass>
softcache
-
Fields inherited from class javassist.ClassPool
childFirstLookup, classes, doPruning, parent, releaseUnmodifiedClassFile, source
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ScopedClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
Create a new ScopedClassPool.protected
ScopedClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, boolean isTemp)
Create a new ScopedClassPool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cacheCtClass(String classname, CtClass c, boolean dynamic)
Cache a classvoid
close()
Close the class poolvoid
flushClass(String classname)
Flush a classprotected CtClass
getCached(String classname)
Get the cached classprotected CtClass
getCachedLocally(String classname)
Whether the class is cached in this pooledClassLoader
getClassLoader()
Get the class loaderprotected ClassLoader
getClassLoader0()
CtClass
getLocally(String classname)
Get any local copy of the classboolean
isUnloadedClassLoader()
Whether the classloader is loadervoid
lockInCache(CtClass c)
Lock a class into the cachevoid
soften(CtClass clazz)
Soften a classClass<?>
toClass(CtClass ct, ClassLoader loader, ProtectionDomain domain)
Convert a javassist class to a java class-
Methods inherited from class javassist.ClassPool
appendClassPath, appendClassPath, appendPathList, appendSystemPath, clearImportedPackages, createCtClass, find, get, get, get0, getAndRename, getCtClass, getDefault, getImportedPackages, getMethod, getOrNull, importPackage, insertClassPath, insertClassPath, lookupCflow, makeAnnotation, makeClass, makeClass, makeClass, makeClass, makeClass, makeClass, makeClassIfNew, makeInterface, makeInterface, makePackage, recordInvalidClassName, removeCached, removeClassPath, toClass, toClass, toString
-
-
-
-
Field Detail
-
repository
protected ScopedClassPoolRepository repository
-
classLoader
protected Reference<ClassLoader> classLoader
-
classPath
protected LoaderClassPath classPath
-
-
Constructor Detail
-
ScopedClassPool
protected ScopedClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
Create a new ScopedClassPool.- Parameters:
cl
- the classloadersrc
- the original class poolrepository
- the repository
-
ScopedClassPool
protected ScopedClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, boolean isTemp)
Create a new ScopedClassPool.- Parameters:
cl
- the classloadersrc
- the original class poolrepository
- the repositoryisTemp
- Whether this is a temporary pool used to resolve references
-
-
Method Detail
-
getClassLoader
public ClassLoader getClassLoader()
Get the class loader- Overrides:
getClassLoader
in classClassPool
- Returns:
- the class loader
- See Also:
ClassPool.toClass(CtClass)
,CtClass.getAnnotations()
-
getClassLoader0
protected ClassLoader getClassLoader0()
-
close
public void close()
Close the class pool
-
flushClass
public void flushClass(String classname)
Flush a class- Parameters:
classname
- the class to flush
-
soften
public void soften(CtClass clazz)
Soften a class- Parameters:
clazz
- the class
-
isUnloadedClassLoader
public boolean isUnloadedClassLoader()
Whether the classloader is loader- Returns:
- false always
-
getCached
protected CtClass getCached(String classname)
Get the cached class- Overrides:
getCached
in classClassPool
- Parameters:
classname
- the class name- Returns:
- the class
- See Also:
ClassPool.cacheCtClass(String,CtClass,boolean)
,ClassPool.removeCached(String)
-
cacheCtClass
protected void cacheCtClass(String classname, CtClass c, boolean dynamic)
Cache a class- Overrides:
cacheCtClass
in classClassPool
- Parameters:
classname
- the class namec
- the ctClassdynamic
- whether the class is dynamically generated- See Also:
ClassPool.getCached(String)
,ClassPool.removeCached(String)
-
lockInCache
public void lockInCache(CtClass c)
Lock a class into the cache- Parameters:
c
- the class
-
getCachedLocally
protected CtClass getCachedLocally(String classname)
Whether the class is cached in this pooled- Parameters:
classname
- the class name- Returns:
- the cached class
-
getLocally
public CtClass getLocally(String classname) throws NotFoundException
Get any local copy of the class- Parameters:
classname
- the class name- Returns:
- the class
- Throws:
NotFoundException
- when the class is not found
-
toClass
public Class<?> toClass(CtClass ct, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
Convert a javassist class to a java class- Overrides:
toClass
in classClassPool
- Parameters:
ct
- the javassist classloader
- the loaderdomain
- the protection domain for the class. If it is null, the default domain created byjava.lang.ClassLoader
is used.- Throws:
CannotCompileException
- for any error- See Also:
ClassPool.getClassLoader()
-
-