diff options
Diffstat (limited to 'src/main/javassist')
-rw-r--r-- | src/main/javassist/ClassPool.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index 6cf67a44..7fc192d2 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -83,6 +83,14 @@ public class ClassPool { protected Hashtable classes; // should be synchronous + /** + * Provide a hook so that subclasses can do their own + * caching of classes + */ + protected CtClass getCached(String classname) + { + return (CtClass)classes.get(classname); + } /** * Creates a class pool. * @@ -434,12 +442,12 @@ public class ClassPool { boolean callback) throws NotFoundException, CannotCompileException, IOException { - CtClass clazz = (CtClass)classes.get(classname); + CtClass clazz = (CtClass)getCached(classname); if (callback && translator != null && (clazz == null || !clazz.isFrozen())) { translator.onWrite(this, classname); // The CtClass object might be overwritten. - clazz = (CtClass)classes.get(classname); + clazz = (CtClass)getCached(classname); } if (clazz == null || !clazz.isModified()) { @@ -464,7 +472,7 @@ public class ClassPool { * Is invoked by CtClassType.setName(). */ synchronized void classNameChanged(String oldname, CtClass clazz) { - CtClass c = (CtClass)classes.get(oldname); + CtClass c = (CtClass)getCached(oldname); if (c == clazz) // must check this equation classes.remove(c); @@ -527,7 +535,7 @@ public class ClassPool { return clazz; } - private CtClass get0(String classname) throws NotFoundException { + protected CtClass get0(String classname) throws NotFoundException { if (classname.endsWith("[]")) return new CtArray(classname, this); else { |