final ClassAdapter filter2) throws Exception
{
if (!Arrays.equals(cr1.b, cr2.b)) {
StringWriter sw1 = new StringWriter();
StringWriter sw2 = new StringWriter();
ClassVisitor cv1 = new TraceClassVisitor(new PrintWriter(sw1));
ClassVisitor cv2 = new TraceClassVisitor(new PrintWriter(sw2));
if (filter1 != null) {
filter1.cv = cv1;
}
if (filter2 != null) {
filter2.cv = cv2;
}
cr1.accept(filter1 == null ? cv1 : filter1, 0);
cr2.accept(filter2 == null ? cv2 : filter2, 0);
String s1 = sw1.toString();
String s2 = sw2.toString();
try {
assertEquals("different data", s1, s2);
} catch (Throwable e) {
/*
* ClassReader may introduce unused labels in the code, due to
* the way uninitialized frame types are handled (false
* positives may occur, see the doc of ClassReader). These
* unused labels may differ before / after a transformation, but
* this does not change the method code itself. Thus, if a
* difference occurs, we retry a comparison, this time by
* removing the unused labels first (we do not do this in the
* first place because it is costly).
*/
sw1 = new StringWriter();
sw2 = new StringWriter();
cv1 = new RemoveUnusedLabelsAdapter(new TraceClassVisitor(new PrintWriter(sw1)));
cv2 = new RemoveUnusedLabelsAdapter(new TraceClassVisitor(new PrintWriter(sw2)));
if (filter1 != null) {
filter1.cv = cv1;
}
if (filter2 != null) {
filter2.cv = cv2;