}
}
private void replaceReferences(final CtClass clazz) throws Exception
{
CodeConverter conv = new CodeConverter();
AOPClassPool pool = AOPClassPool
.createAOPClassPool(clazz.getClassPool(), AOPClassPoolRepository.getInstance());
Collection<String> refs = AccessController.doPrivileged(new PrivilegedAction<Collection<String>>() {
public Collection<String> run()
{
return clazz.getRefClasses();
}});
for (String ref : refs)
{
if (ref.startsWith(PACKAGE_REPLACEMENT_CHILD) || ref.startsWith(PACKAGE_REPLACEMENT_PARENT))
{
if (ref.endsWith("Caller"))
{
continue;
}
CtClass ctRef = pool.get(ref);
CtField[] fields = ctRef.getDeclaredFields();
for (CtField fld : fields)
{
conv.replaceFieldRead(fld, ctRef, getFieldReadWrapperName(fld.getName()));
conv.replaceFieldWrite(fld, ctRef, getFieldWriteWrapperName(fld.getName()));
}
conv.replaceNew(ctRef, ctRef, getConstructorName(ctRef));
}
}
clazz.instrument(conv);
}