Class ScopedClassPool
- java.lang.Object
-
- org.hotswap.agent.javassist.ClassPool
-
- org.hotswap.agent.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>classLoaderprotected LoaderClassPathclassPathprotected ScopedClassPoolRepositoryrepositoryprotected Map<String,CtClass>softcache-
Fields inherited from class org.hotswap.agent.javassist.ClassPool
classes, doPruning, childFirstLookup, parent, releaseUnmodifiedClassFile, source
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedScopedClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)Create a new ScopedClassPool.protectedScopedClassPool(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 voidcacheCtClass(String classname, CtClass c, boolean dynamic)Cache a classvoidclose()Close the class poolvoidflushClass(String classname)Flush a classprotected CtClassgetCached(String classname)Get the cached classprotected CtClassgetCachedLocally(String classname)Whether the class is cached in this pooledClassLoadergetClassLoader()Get the class loaderprotected ClassLoadergetClassLoader0()CtClassgetLocally(String classname)Get any local copy of the classbooleanisUnloadedClassLoader()Whether the classloader is loadervoidlockInCache(CtClass c)Lock a class into the cachevoidsoften(CtClass clazz)Soften a classClass<?>toClass(CtClass ct, ClassLoader loader, ProtectionDomain domain)Convert a javassist class to a java class-
Methods inherited from class org.hotswap.agent.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, toClass, 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:
getClassLoaderin 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:
getCachedin 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:
cacheCtClassin 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:
toClassin classClassPool- Parameters:
ct- the javassist classloader- the loaderdomain- the protection domain for the class. If it is null, the default domain created byjava.lang.ClassLoaderis used.- Throws:
CannotCompileException- for any error- See Also:
ClassPool.getClassLoader()
-
-