1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -103,8 +103,8 @@ private Map<Member, String[]> inspectClass(Class<?> clazz) {
103
103
// We couldn't load the class file, which is not fatal as it
104
104
// simply means this method of discovering parameter names won't work.
105
105
if (logger .isDebugEnabled ()) {
106
- logger .debug ("Cannot find '.class' file for class [" + clazz
107
- + "] - unable to determine constructors/methods parameter names" );
106
+ logger .debug ("Cannot find '.class' file for class [" + clazz +
107
+ "] - unable to determine constructor/method parameter names" );
108
108
}
109
109
return NO_DEBUG_INFO_MAP ;
110
110
}
@@ -117,14 +117,14 @@ private Map<Member, String[]> inspectClass(Class<?> clazz) {
117
117
catch (IOException ex ) {
118
118
if (logger .isDebugEnabled ()) {
119
119
logger .debug ("Exception thrown while reading '.class' file for class [" + clazz +
120
- "] - unable to determine constructors/methods parameter names" , ex );
120
+ "] - unable to determine constructor/method parameter names" , ex );
121
121
}
122
122
}
123
123
catch (IllegalArgumentException ex ) {
124
124
if (logger .isDebugEnabled ()) {
125
125
logger .debug ("ASM ClassReader failed to parse class file [" + clazz +
126
126
"], probably due to a new Java class file version that isn't supported yet " +
127
- "- unable to determine constructors/methods parameter names" , ex );
127
+ "- unable to determine constructor/method parameter names" , ex );
128
128
}
129
129
}
130
130
finally {
@@ -148,6 +148,7 @@ private static class ParameterNameDiscoveringVisitor extends ClassVisitor {
148
148
private static final String STATIC_CLASS_INIT = "<clinit>" ;
149
149
150
150
private final Class <?> clazz ;
151
+
151
152
private final Map <Member , String []> memberMap ;
152
153
153
154
public ParameterNameDiscoveringVisitor (Class <?> clazz , Map <Member , String []> memberMap ) {
@@ -180,12 +181,17 @@ private static class LocalVariableTableVisitor extends MethodVisitor {
180
181
private static final String CONSTRUCTOR = "<init>" ;
181
182
182
183
private final Class <?> clazz ;
184
+
183
185
private final Map <Member , String []> memberMap ;
186
+
184
187
private final String name ;
188
+
185
189
private final Type [] args ;
190
+
191
+ private final String [] parameterNames ;
192
+
186
193
private final boolean isStatic ;
187
194
188
- private String [] parameterNames ;
189
195
private boolean hasLvtInfo = false ;
190
196
191
197
/*
@@ -194,25 +200,22 @@ private static class LocalVariableTableVisitor extends MethodVisitor {
194
200
*/
195
201
private final int [] lvtSlotIndex ;
196
202
197
- public LocalVariableTableVisitor (Class <?> clazz , Map <Member , String []> map , String name , String desc ,
198
- boolean isStatic ) {
203
+ public LocalVariableTableVisitor (Class <?> clazz , Map <Member , String []> map , String name , String desc , boolean isStatic ) {
199
204
super (SpringAsmInfo .ASM_VERSION );
200
205
this .clazz = clazz ;
201
206
this .memberMap = map ;
202
207
this .name = name ;
203
- // determine args
204
- args = Type .getArgumentTypes (desc );
205
- this .parameterNames = new String [args .length ];
208
+ this .args = Type .getArgumentTypes (desc );
209
+ this .parameterNames = new String [this .args .length ];
206
210
this .isStatic = isStatic ;
207
- this .lvtSlotIndex = computeLvtSlotIndices (isStatic , args );
211
+ this .lvtSlotIndex = computeLvtSlotIndices (isStatic , this . args );
208
212
}
209
213
210
214
@ Override
211
- public void visitLocalVariable (String name , String description , String signature , Label start , Label end ,
212
- int index ) {
215
+ public void visitLocalVariable (String name , String description , String signature , Label start , Label end , int index ) {
213
216
this .hasLvtInfo = true ;
214
- for (int i = 0 ; i < lvtSlotIndex .length ; i ++) {
215
- if (lvtSlotIndex [i ] == index ) {
217
+ for (int i = 0 ; i < this . lvtSlotIndex .length ; i ++) {
218
+ if (this . lvtSlotIndex [i ] == index ) {
216
219
this .parameterNames [i ] = name ;
217
220
}
218
221
}
@@ -225,27 +228,25 @@ public void visitEnd() {
225
228
// which doesn't use any local variables.
226
229
// This means that hasLvtInfo could be false for that kind of methods
227
230
// even if the class has local variable info.
228
- memberMap .put (resolveMember (), parameterNames );
231
+ this . memberMap .put (resolveMember (), this . parameterNames );
229
232
}
230
233
}
231
234
232
235
private Member resolveMember () {
233
- ClassLoader loader = clazz .getClassLoader ();
234
- Class <?>[] classes = new Class <?>[args .length ];
235
-
236
- // resolve args
237
- for (int i = 0 ; i < args .length ; i ++) {
238
- classes [i ] = ClassUtils .resolveClassName (args [i ].getClassName (), loader );
236
+ ClassLoader loader = this .clazz .getClassLoader ();
237
+ Class <?>[] argTypes = new Class <?>[this .args .length ];
238
+ for (int i = 0 ; i < this .args .length ; i ++) {
239
+ argTypes [i ] = ClassUtils .resolveClassName (this .args [i ].getClassName (), loader );
239
240
}
240
241
try {
241
- if (CONSTRUCTOR .equals (name )) {
242
- return clazz .getDeclaredConstructor (classes );
242
+ if (CONSTRUCTOR .equals (this . name )) {
243
+ return this . clazz .getDeclaredConstructor (argTypes );
243
244
}
244
-
245
- return clazz . getDeclaredMethod ( name , classes );
246
- } catch (NoSuchMethodException ex ) {
247
- throw new IllegalStateException ("Method [" + name
248
- + "] was discovered in the .class file but cannot be resolved in the class object" , ex );
245
+ return this . clazz . getDeclaredMethod ( this . name , argTypes );
246
+ }
247
+ catch (NoSuchMethodException ex ) {
248
+ throw new IllegalStateException ("Method [" + this . name +
249
+ "] was discovered in the .class file but cannot be resolved in the class object" , ex );
249
250
}
250
251
}
251
252
@@ -256,7 +257,8 @@ private static int[] computeLvtSlotIndices(boolean isStatic, Type[] paramTypes)
256
257
lvtIndex [i ] = nextIndex ;
257
258
if (isWideType (paramTypes [i ])) {
258
259
nextIndex += 2 ;
259
- } else {
260
+ }
261
+ else {
260
262
nextIndex ++;
261
263
}
262
264
}
0 commit comments