|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2013 the original author or authors. |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -103,8 +103,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD |
|
|
|
// We couldn't load the class file, which is not fatal as it
|
|
|
|
// We couldn't load the class file, which is not fatal as it
|
|
|
|
// simply means this method of discovering parameter names won't work.
|
|
|
|
// simply means this method of discovering parameter names won't work.
|
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug("Cannot find '.class' file for class [" + clazz |
|
|
|
logger.debug("Cannot find '.class' file for class [" + clazz + |
|
|
|
+ "] - unable to determine constructors/methods parameter names"); |
|
|
|
"] - unable to determine constructor/method parameter names"); |
|
|
|
} |
|
|
|
} |
|
|
|
return NO_DEBUG_INFO_MAP; |
|
|
|
return NO_DEBUG_INFO_MAP; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -117,14 +117,14 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD |
|
|
|
catch (IOException ex) { |
|
|
|
catch (IOException ex) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug("Exception thrown while reading '.class' file for class [" + clazz + |
|
|
|
logger.debug("Exception thrown while reading '.class' file for class [" + clazz + |
|
|
|
"] - unable to determine constructors/methods parameter names", ex); |
|
|
|
"] - unable to determine constructor/method parameter names", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (IllegalArgumentException ex) { |
|
|
|
catch (IllegalArgumentException ex) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug("ASM ClassReader failed to parse class file [" + clazz + |
|
|
|
logger.debug("ASM ClassReader failed to parse class file [" + clazz + |
|
|
|
"], probably due to a new Java class file version that isn't supported yet " + |
|
|
|
"], probably due to a new Java class file version that isn't supported yet " + |
|
|
|
"- unable to determine constructors/methods parameter names", ex); |
|
|
|
"- unable to determine constructor/method parameter names", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
finally { |
|
|
|
finally { |
|
|
|
@ -148,6 +148,7 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD |
|
|
|
private static final String STATIC_CLASS_INIT = "<clinit>"; |
|
|
|
private static final String STATIC_CLASS_INIT = "<clinit>"; |
|
|
|
|
|
|
|
|
|
|
|
private final Class<?> clazz; |
|
|
|
private final Class<?> clazz; |
|
|
|
|
|
|
|
|
|
|
|
private final Map<Member, String[]> memberMap; |
|
|
|
private final Map<Member, String[]> memberMap; |
|
|
|
|
|
|
|
|
|
|
|
public ParameterNameDiscoveringVisitor(Class<?> clazz, Map<Member, String[]> memberMap) { |
|
|
|
public ParameterNameDiscoveringVisitor(Class<?> clazz, Map<Member, String[]> memberMap) { |
|
|
|
@ -180,12 +181,17 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD |
|
|
|
private static final String CONSTRUCTOR = "<init>"; |
|
|
|
private static final String CONSTRUCTOR = "<init>"; |
|
|
|
|
|
|
|
|
|
|
|
private final Class<?> clazz; |
|
|
|
private final Class<?> clazz; |
|
|
|
|
|
|
|
|
|
|
|
private final Map<Member, String[]> memberMap; |
|
|
|
private final Map<Member, String[]> memberMap; |
|
|
|
|
|
|
|
|
|
|
|
private final String name; |
|
|
|
private final String name; |
|
|
|
|
|
|
|
|
|
|
|
private final Type[] args; |
|
|
|
private final Type[] args; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final String[] parameterNames; |
|
|
|
|
|
|
|
|
|
|
|
private final boolean isStatic; |
|
|
|
private final boolean isStatic; |
|
|
|
|
|
|
|
|
|
|
|
private String[] parameterNames; |
|
|
|
|
|
|
|
private boolean hasLvtInfo = false; |
|
|
|
private boolean hasLvtInfo = false; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
@ -194,25 +200,22 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private final int[] lvtSlotIndex; |
|
|
|
private final int[] lvtSlotIndex; |
|
|
|
|
|
|
|
|
|
|
|
public LocalVariableTableVisitor(Class<?> clazz, Map<Member, String[]> map, String name, String desc, |
|
|
|
public LocalVariableTableVisitor(Class<?> clazz, Map<Member, String[]> map, String name, String desc, boolean isStatic) { |
|
|
|
boolean isStatic) { |
|
|
|
|
|
|
|
super(SpringAsmInfo.ASM_VERSION); |
|
|
|
super(SpringAsmInfo.ASM_VERSION); |
|
|
|
this.clazz = clazz; |
|
|
|
this.clazz = clazz; |
|
|
|
this.memberMap = map; |
|
|
|
this.memberMap = map; |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
// determine args
|
|
|
|
this.args = Type.getArgumentTypes(desc); |
|
|
|
args = Type.getArgumentTypes(desc); |
|
|
|
this.parameterNames = new String[this.args.length]; |
|
|
|
this.parameterNames = new String[args.length]; |
|
|
|
|
|
|
|
this.isStatic = isStatic; |
|
|
|
this.isStatic = isStatic; |
|
|
|
this.lvtSlotIndex = computeLvtSlotIndices(isStatic, args); |
|
|
|
this.lvtSlotIndex = computeLvtSlotIndices(isStatic, this.args); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void visitLocalVariable(String name, String description, String signature, Label start, Label end, |
|
|
|
public void visitLocalVariable(String name, String description, String signature, Label start, Label end, int index) { |
|
|
|
int index) { |
|
|
|
|
|
|
|
this.hasLvtInfo = true; |
|
|
|
this.hasLvtInfo = true; |
|
|
|
for (int i = 0; i < lvtSlotIndex.length; i++) { |
|
|
|
for (int i = 0; i < this.lvtSlotIndex.length; i++) { |
|
|
|
if (lvtSlotIndex[i] == index) { |
|
|
|
if (this.lvtSlotIndex[i] == index) { |
|
|
|
this.parameterNames[i] = name; |
|
|
|
this.parameterNames[i] = name; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -225,27 +228,25 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD |
|
|
|
// which doesn't use any local variables.
|
|
|
|
// which doesn't use any local variables.
|
|
|
|
// This means that hasLvtInfo could be false for that kind of methods
|
|
|
|
// This means that hasLvtInfo could be false for that kind of methods
|
|
|
|
// even if the class has local variable info.
|
|
|
|
// even if the class has local variable info.
|
|
|
|
memberMap.put(resolveMember(), parameterNames); |
|
|
|
this.memberMap.put(resolveMember(), this.parameterNames); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Member resolveMember() { |
|
|
|
private Member resolveMember() { |
|
|
|
ClassLoader loader = clazz.getClassLoader(); |
|
|
|
ClassLoader loader = this.clazz.getClassLoader(); |
|
|
|
Class<?>[] classes = new Class<?>[args.length]; |
|
|
|
Class<?>[] argTypes = new Class<?>[this.args.length]; |
|
|
|
|
|
|
|
for (int i = 0; i < this.args.length; i++) { |
|
|
|
// resolve args
|
|
|
|
argTypes[i] = ClassUtils.resolveClassName(this.args[i].getClassName(), loader); |
|
|
|
for (int i = 0; i < args.length; i++) { |
|
|
|
|
|
|
|
classes[i] = ClassUtils.resolveClassName(args[i].getClassName(), loader); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (CONSTRUCTOR.equals(name)) { |
|
|
|
if (CONSTRUCTOR.equals(this.name)) { |
|
|
|
return clazz.getDeclaredConstructor(classes); |
|
|
|
return this.clazz.getDeclaredConstructor(argTypes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return this.clazz.getDeclaredMethod(this.name, argTypes); |
|
|
|
return clazz.getDeclaredMethod(name, classes); |
|
|
|
} |
|
|
|
} catch (NoSuchMethodException ex) { |
|
|
|
catch (NoSuchMethodException ex) { |
|
|
|
throw new IllegalStateException("Method [" + name |
|
|
|
throw new IllegalStateException("Method [" + this.name + |
|
|
|
+ "] was discovered in the .class file but cannot be resolved in the class object", ex); |
|
|
|
"] was discovered in the .class file but cannot be resolved in the class object", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -256,7 +257,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD |
|
|
|
lvtIndex[i] = nextIndex; |
|
|
|
lvtIndex[i] = nextIndex; |
|
|
|
if (isWideType(paramTypes[i])) { |
|
|
|
if (isWideType(paramTypes[i])) { |
|
|
|
nextIndex += 2; |
|
|
|
nextIndex += 2; |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
nextIndex++; |
|
|
|
nextIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|