22
22
import com .google .common .collect .Maps ;
23
23
24
24
import org .objectweb .asm .AnnotationVisitor ;
25
- import org .objectweb .asm .Attribute ;
26
25
import org .objectweb .asm .ClassReader ;
27
26
import org .objectweb .asm .ClassVisitor ;
28
27
import org .objectweb .asm .FieldVisitor ;
@@ -123,12 +122,16 @@ private String memberKey(Member member) {
123
122
end[NO_AOP]*/
124
123
}
125
124
126
- private class LineNumberReader implements ClassVisitor , MethodVisitor , AnnotationVisitor {
125
+ private class LineNumberReader extends ClassVisitor {
127
126
128
127
private int line = -1 ;
129
128
private String pendingMethod ;
130
129
private String name ;
131
130
131
+ LineNumberReader () {
132
+ super (Opcodes .ASM4 );
133
+ }
134
+
132
135
public void visit (int version , int access , String name , String signature ,
133
136
String superName , String [] interfaces ) {
134
137
this .name = name ;
@@ -141,7 +144,7 @@ public MethodVisitor visitMethod(int access, String name, String desc,
141
144
}
142
145
pendingMethod = name + desc ;
143
146
line = -1 ;
144
- return this ;
147
+ return new LineNumberMethodVisitor () ;
145
148
}
146
149
147
150
public void visitSource (String source , String debug ) {
@@ -160,113 +163,61 @@ public void visitLineNumber(int line, Label start) {
160
163
}
161
164
}
162
165
163
- public void visitFieldInsn (int opcode , String owner , String name ,
164
- String desc ) {
165
- if (opcode == Opcodes .PUTFIELD && this .name .equals (owner )
166
- && !lines .containsKey (name ) && line != -1 ) {
167
- lines .put (name , line );
168
- }
169
- }
170
-
171
- public void visitEnd () {
172
- }
173
-
174
- public void visitInnerClass (String name , String outerName , String innerName ,
175
- int access ) {
176
- }
177
-
178
- public void visitOuterClass (String owner , String name , String desc ) {
179
- }
180
-
181
- public void visitAttribute (Attribute attr ) {
182
- }
183
-
184
166
public FieldVisitor visitField (int access , String name , String desc ,
185
167
String signature , Object value ) {
186
168
return null ;
187
169
}
188
170
189
171
public AnnotationVisitor visitAnnotation (String desc , boolean visible ) {
190
- return this ;
191
- }
192
-
193
- public AnnotationVisitor visitAnnotation (String name , String desc ) {
194
- return this ;
195
- }
196
-
197
- public AnnotationVisitor visitAnnotationDefault () {
198
- return this ;
172
+ return new LineNumberAnnotationVisitor ();
199
173
}
200
174
201
175
public AnnotationVisitor visitParameterAnnotation (int parameter ,
202
176
String desc , boolean visible ) {
203
- return this ;
177
+ return new LineNumberAnnotationVisitor () ;
204
178
}
205
179
206
- public AnnotationVisitor visitArray (String name ) {
207
- return this ;
180
+ class LineNumberMethodVisitor extends MethodVisitor {
181
+ LineNumberMethodVisitor () {
182
+ super (Opcodes .ASM4 );
208
183
}
209
184
210
- public void visitEnum (String name , String desc , String value ) {
185
+ public AnnotationVisitor visitAnnotation (String desc , boolean visible ) {
186
+ return new LineNumberAnnotationVisitor ();
211
187
}
212
188
213
- public void visit (String name , Object value ) {
189
+ public AnnotationVisitor visitAnnotationDefault () {
190
+ return new LineNumberAnnotationVisitor ();
214
191
}
215
192
216
- public void visitCode () {
193
+ public void visitFieldInsn (int opcode , String owner , String name ,
194
+ String desc ) {
195
+ if (opcode == Opcodes .PUTFIELD && LineNumberReader .this .name .equals (owner )
196
+ && !lines .containsKey (name ) && line != -1 ) {
197
+ lines .put (name , line );
217
198
}
218
-
219
- public void visitFrame (int type , int nLocal , Object [] local , int nStack ,
220
- Object [] stack ) {
221
199
}
222
200
223
- public void visitIincInsn (int var , int increment ) {
201
+ public void visitLineNumber (int line , Label start ) {
202
+ LineNumberReader .this .visitLineNumber (line , start );
224
203
}
225
-
226
- public void visitInsn (int opcode ) {
227
204
}
228
205
229
- public void visitIntInsn (int opcode , int operand ) {
206
+ class LineNumberAnnotationVisitor extends AnnotationVisitor {
207
+ LineNumberAnnotationVisitor () {
208
+ super (Opcodes .ASM4 );
230
209
}
231
-
232
- public void visitJumpInsn ( int opcode , Label label ) {
210
+ public AnnotationVisitor visitAnnotation ( String name , String desc ) {
211
+ return this ;
233
212
}
234
-
235
- public void visitLabel ( Label label ) {
213
+ public AnnotationVisitor visitArray ( String name ) {
214
+ return this ;
236
215
}
237
-
238
- public void visitLdcInsn (Object cst ) {
239
- }
240
-
241
216
public void visitLocalVariable (String name , String desc , String signature ,
242
217
Label start , Label end , int index ) {
243
218
}
244
219
245
- public void visitLookupSwitchInsn (Label dflt , int [] keys , Label [] labels ) {
246
- }
247
-
248
- public void visitMaxs (int maxStack , int maxLocals ) {
249
- }
250
-
251
- public void visitMethodInsn (int opcode , String owner , String name ,
252
- String desc ) {
253
220
}
254
221
255
- public void visitMultiANewArrayInsn (String desc , int dims ) {
256
- }
257
-
258
- public void visitTableSwitchInsn (int min , int max , Label dflt ,
259
- Label [] labels ) {
260
- }
261
-
262
- public void visitTryCatchBlock (Label start , Label end , Label handler ,
263
- String type ) {
264
- }
265
-
266
- public void visitTypeInsn (int opcode , String desc ) {
267
- }
268
-
269
- public void visitVarInsn (int opcode , int var ) {
270
- }
271
222
}
272
223
}
0 commit comments