Browse Source

- 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
tags/rel_3_17_1_ga
patriot1burke 21 years ago
parent
commit
da450cf0f7
1 changed files with 12 additions and 4 deletions
  1. 12
    4
      src/main/javassist/ClassPool.java

+ 12
- 4
src/main/javassist/ClassPool.java View File

@@ -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 {

Loading…
Cancel
Save