1b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/*
2b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ProGuard -- shrinking, optimization, obfuscation, and preverification
3b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *             of Java bytecode.
4b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
52270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu)
6b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
7b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is free software; you can redistribute it and/or modify it
8b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * under the terms of the GNU General Public License as published by the Free
9b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Software Foundation; either version 2 of the License, or (at your option)
10b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * any later version.
11b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
12b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is distributed in the hope that it will be useful, but WITHOUT
13b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * more details.
16b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
17b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * You should have received a copy of the GNU General Public License along
18b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * with this program; if not, write to the Free Software Foundation, Inc.,
19b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
21b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopackage proguard.optimize;
22b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
23b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.*;
24b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.attribute.*;
25b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.attribute.annotation.*;
26b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.attribute.preverification.*;
27b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.attribute.visitor.AttributeVisitor;
28b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.util.ClassUtil;
29b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
30b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/**
31b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This AttributeVisitor delegates its call to another AttributeVisitor, and
32b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * prints out the code if the other visitor has changed it.
33b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
34b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * @author Eric Lafortune
35b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
36b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopublic class ChangedCodePrinter
37b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimplements   AttributeVisitor
38b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato{
39b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final AttributeVisitor attributeVisitor;
40b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
41b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
42b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public ChangedCodePrinter(AttributeVisitor attributeVisitor)
43b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
44b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        this.attributeVisitor = attributeVisitor;
45b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
46b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
47b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
48b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementations for AttributeVisitor.
49b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
50b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitUnknownAttribute(Clazz clazz, UnknownAttribute unknownAttribute)
51b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
52b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitUnknownAttribute(clazz, unknownAttribute);
53b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
54b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
55b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
56b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang    public void visitBootstrapMethodsAttribute(Clazz clazz, BootstrapMethodsAttribute bootstrapMethodsAttribute)
57b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang    {
58b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang        attributeVisitor.visitBootstrapMethodsAttribute(clazz, bootstrapMethodsAttribute);
59b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang    }
60b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang
61b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang
62b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute)
63b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
64b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSourceFileAttribute(clazz, sourceFileAttribute);
65b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
66b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
67b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
68b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSourceDirAttribute(Clazz clazz, SourceDirAttribute sourceDirAttribute)
69b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
70b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSourceDirAttribute(clazz, sourceDirAttribute);
71b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
72b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
73b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
74b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute)
75b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
76b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitInnerClassesAttribute(clazz, innerClassesAttribute);
77b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
78b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
79b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
80b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute)
81b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
82b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitEnclosingMethodAttribute(clazz, enclosingMethodAttribute);
83b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
84b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
85b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
86b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitDeprecatedAttribute(Clazz clazz, DeprecatedAttribute deprecatedAttribute)
87b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
88b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitDeprecatedAttribute(clazz, deprecatedAttribute);
89b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
90b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
91b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
92b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSyntheticAttribute(Clazz clazz, SyntheticAttribute syntheticAttribute)
93b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
94b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSyntheticAttribute(clazz, syntheticAttribute);
95b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
96b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
97b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
98b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSignatureAttribute(Clazz clazz, SignatureAttribute syntheticAttribute)
99b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
100b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSignatureAttribute(clazz, syntheticAttribute);
101b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
102b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
103b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
104b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitDeprecatedAttribute(Clazz clazz, Field field, DeprecatedAttribute deprecatedAttribute)
105b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
106b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitDeprecatedAttribute(clazz, field, deprecatedAttribute);
107b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
108b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
109b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
110b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSyntheticAttribute(Clazz clazz, Field field, SyntheticAttribute syntheticAttribute)
111b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
112b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSyntheticAttribute(clazz, field, syntheticAttribute);
113b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
114b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
115b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
116b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSignatureAttribute(Clazz clazz, Field field, SignatureAttribute syntheticAttribute)
117b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
118b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSignatureAttribute(clazz, field, syntheticAttribute);
119b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
120b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
121b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
122b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitDeprecatedAttribute(Clazz clazz, Method method, DeprecatedAttribute deprecatedAttribute)
123b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
124b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitDeprecatedAttribute(clazz, method, deprecatedAttribute);
125b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
126b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
127b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
128b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSyntheticAttribute(Clazz clazz, Method method, SyntheticAttribute syntheticAttribute)
129b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
130b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSyntheticAttribute(clazz, method, syntheticAttribute);
131b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
132b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
133b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
134b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitSignatureAttribute(Clazz clazz, Method method, SignatureAttribute syntheticAttribute)
135b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
136b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitSignatureAttribute(clazz, method, syntheticAttribute);
137b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
138b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
139b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
140b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitConstantValueAttribute(Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute)
141b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
142b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitConstantValueAttribute(clazz, field, constantValueAttribute);
143b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
144b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
145b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
1462270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitMethodParametersAttribute(Clazz clazz, Method method, MethodParametersAttribute exceptionsAttribute)
1472270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
1482270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitMethodParametersAttribute(clazz, method, exceptionsAttribute);
1492270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
1502270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
1512270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
152b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitExceptionsAttribute(Clazz clazz, Method method, ExceptionsAttribute exceptionsAttribute)
153b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
154b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitExceptionsAttribute(clazz, method, exceptionsAttribute);
155b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
156b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
157b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
158b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitStackMapAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute)
159b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
160b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitStackMapAttribute(clazz, method, codeAttribute, stackMapAttribute);
161b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
162b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
163b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
164b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitStackMapTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute)
165b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
166b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitStackMapTableAttribute(clazz, method, codeAttribute, stackMapTableAttribute);
167b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
168b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
169b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
170b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute)
171b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
172b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitLineNumberTableAttribute(clazz, method, codeAttribute, lineNumberTableAttribute);
173b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
174b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
175b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
176b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute)
177b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
178b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitLocalVariableTableAttribute(clazz, method, codeAttribute, localVariableTableAttribute);
179b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
180b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
181b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
182b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute)
183b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
184b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitLocalVariableTypeTableAttribute(clazz, method, codeAttribute, localVariableTypeTableAttribute);
185b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
186b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
187b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
188b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute)
189b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
190b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, runtimeVisibleAnnotationsAttribute);
191b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
192b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
193b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
194b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute)
195b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
196b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, runtimeInvisibleAnnotationsAttribute);
197b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
198b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
199b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
200b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute)
201b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
202b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, field, runtimeVisibleAnnotationsAttribute);
203b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
204b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
205b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
206b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute)
207b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
208b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, field, runtimeInvisibleAnnotationsAttribute);
209b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
210b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
211b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
212b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute)
213b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
214b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeVisibleAnnotationsAttribute(clazz, method, runtimeVisibleAnnotationsAttribute);
215b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
216b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
217b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
218b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute)
219b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
220b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeInvisibleAnnotationsAttribute(clazz, method, runtimeInvisibleAnnotationsAttribute);
221b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
222b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
223b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
224b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeVisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleParameterAnnotationsAttribute runtimeVisibleParameterAnnotationsAttribute)
225b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
226b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeVisibleParameterAnnotationsAttribute(clazz, method, runtimeVisibleParameterAnnotationsAttribute);
227b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
228b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
229b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
230b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitRuntimeInvisibleParameterAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleParameterAnnotationsAttribute runtimeInvisibleParameterAnnotationsAttribute)
231b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
232b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitRuntimeInvisibleParameterAnnotationsAttribute(clazz, method, runtimeInvisibleParameterAnnotationsAttribute);
233b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
234b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
235b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
2362270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute)
2372270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2382270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, runtimeVisibleTypeAnnotationsAttribute);
2392270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2402270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2412270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2422270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute)
2432270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2442270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, field, runtimeVisibleTypeAnnotationsAttribute);
2452270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2462270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2472270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2482270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute)
2492270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2502270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, runtimeVisibleTypeAnnotationsAttribute);
2512270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2522270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2532270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2542270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute)
2552270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2562270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeVisibleTypeAnnotationsAttribute);
2572270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2582270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2592270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2602270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute)
2612270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2622270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, runtimeInvisibleTypeAnnotationsAttribute);
2632270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2642270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2652270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2662270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute)
2672270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2682270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, field, runtimeInvisibleTypeAnnotationsAttribute);
2692270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2702270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2712270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2722270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute)
2732270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2742270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, runtimeInvisibleTypeAnnotationsAttribute);
2752270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2762270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2772270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2782270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute)
2792270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    {
2802270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom        attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, runtimeInvisibleTypeAnnotationsAttribute);
2812270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom    }
2822270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
2832270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom
284b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute)
285b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
286b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitAnnotationDefaultAttribute(clazz, method, annotationDefaultAttribute);
287b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
288b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
289b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
290b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
291b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
292b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        byte[] code    = codeAttribute.code;
293b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        byte[] oldCode = new byte[code.length];
294b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
295b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Copy the current code.
296b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        System.arraycopy(code, 0, oldCode, 0, codeAttribute.u4codeLength);
297b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
298b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Delegate to the real visitor.
299b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        attributeVisitor.visitCodeAttribute(clazz, method, codeAttribute);
300b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
301b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Check if the code has changed.
302b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        if (codeHasChanged(codeAttribute, oldCode))
303b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
304b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            printChangedCode(clazz, method, codeAttribute, oldCode);
305b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
306b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
307b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
308b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
309b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Small utility methods.
310b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
311b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private boolean codeHasChanged(CodeAttribute codeAttribute, byte[] oldCode)
312b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
313b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        if (oldCode.length != codeAttribute.u4codeLength)
314b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
315b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            return true;
316b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
317b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
318b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        for (int index = 0; index < codeAttribute.u4codeLength; index++)
319b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
320b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            if (oldCode[index] != codeAttribute.code[index])
321b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            {
322b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                return true;
323b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            }
324b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
325b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
326b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return false;
327b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
328b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
329b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
330b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private void printChangedCode(Clazz         clazz,
331b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  Method        method,
332b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  CodeAttribute codeAttribute,
333b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                  byte[]        oldCode)
334b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
335b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        System.out.println("Class "+ClassUtil.externalClassName(clazz.getName()));
336b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        System.out.println("Method "+ClassUtil.externalFullMethodDescription(clazz.getName(),
337b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                             0,
338b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                             method.getName(clazz),
339b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                             method.getDescriptor(clazz)));
340b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
341b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        for (int index = 0; index < codeAttribute.u4codeLength; index++)
342b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
343b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            System.out.println(
344b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                (oldCode[index] == codeAttribute.code[index]? "  -- ":"  => ")+
345b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                index+": "+
346b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                Integer.toHexString(0x100|oldCode[index]           &0xff).substring(1)+" "+
347b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                Integer.toHexString(0x100|codeAttribute.code[index]&0xff).substring(1));
348b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
349b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
350b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato}
351