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.
*
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()) {
* 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);
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 {