}
public boolean doWeave(ClassLoader cl, ClassFileInfo info) throws BadBytecode, CannotCompileException
{
CtClass clazz = info.getClazz();
ClassFile file = clazz.getClassFile();
log.fine("weaving: " + info.getClassName());
// Already done
if (file.getMajorVersion() <= 48)
return false;
// Set the major version
file.setMajorVersion(48);
// Rename known classes
file.renameClass(getClassRenames());
ConstPool constPool = file.getConstPool();
// Rename classes with + to have $
HashMap<String, String> mapClasses = new HashMap<String, String>();
for (String name : (Set<String>) constPool.getClassNames())
{
if (name.indexOf('+') != -1) {
mapClasses.put(name, name.replace('+', '$'));
}
}
if (mapClasses.size() != 0) {
constPool.renameClass(mapClasses);
}
// Replace LDC/LDC_W
for (MethodInfo method : (List<MethodInfo>) file.getMethods()) {
rewriteLDC(constPool, method);
}
if (clazz.isAnnotation())
{
rewriteSystemAnnotations(file);
}
// Run the converters
for (CodeConverter converter : this.getCodeConverters())
{
clazz.instrument(converter);
}
// Run the editors
for (ExprEditor editor : this.getExprEditors())
{
clazz.instrument(editor);
}
if (log.isLoggable(Level.FINEST))
{
PrintWriter out = new PrintWriter(System.out, true);
out.println("*** constant pool ***");
file.getConstPool().print(out);
out.println();
out.println("*** members ***");
ClassFileWriter.print(file, out);
}