ClassReader cr = new ClassReader(sourceStream);
ClassWriter cw = new ClassWriter(true);
try {
NameTranslatorClassVisitor translator;
ConstantPool cp;
if (COMPACT_CONSTANTS) {
cp = new ConstantPool();
ClassConstantsCollector ccc = new ClassConstantsCollector(cw, cp);
translator = new NameTranslatorClassVisitor(ccc);
} else {
translator = new NameTranslatorClassVisitor(cw);
}
ClassWeaver classWeaver = new ClassWeaver(translator, lazy, stripAttributes, target, listener);
ClassVisitor v;
if (stripSignatures) {
v = new SignatureStripper(classWeaver);
} else {
v = classWeaver;
}
cr.accept(v, CUSTOM_ATTRIBUTES, false);
if (COMPACT_CONSTANTS) {
Set<Constant> constants = new TreeSet<Constant>(new ConstantComparator());
constants.addAll(cp.values());
cr = new ClassReader(cw.toByteArray());
cw = new ClassWriter(false);
for(Constant c: constants)
c.write(cw);