diff options
author | patriot1burke <patriot1burke@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2003-05-23 23:18:39 +0000 |
---|---|---|
committer | patriot1burke <patriot1burke@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2003-05-23 23:18:39 +0000 |
commit | da450cf0f71a4348672e1a47b7918c24c7d711a9 (patch) | |
tree | 534b913785c9ab39ded394f8c52d0dcc32de69dd /src/main/javassist/ClassPool.java | |
parent | 03e676c3ec809a09ebcc3ee3c2927e903d19e461 (diff) | |
download | javassist-da450cf0f71a4348672e1a47b7918c24c7d711a9.tar.gz javassist-da450cf0f71a4348672e1a47b7918c24c7d711a9.zip |
- Made ClassPool.get0 protected so that subclasses of ClassPool can call it
- Moved all access to the class cache in ClassPool (ClassPool.classes) to a method called getCached(String classname). This is so subclasses of ClassPool can override this behavior.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@22 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/ClassPool.java')
-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 { |