org.springframework.core
public class: LocalVariableTableParameterNameDiscoverer [javadoc |
source]
java.lang.Object
org.springframework.core.LocalVariableTableParameterNameDiscoverer
All Implemented Interfaces:
ParameterNameDiscoverer
Implementation of
ParameterNameDiscoverer that uses the LocalVariableTable
information in the method attributes to discover parameter names. Returns
null if the class file was compiled without debug information.
Uses ObjectWeb's ASM library for analyzing class files. Each discoverer
instance caches the ASM ClassReader for each introspected Class, in a
thread-safe manner. It is recommended to reuse discoverer instances
as far as possible.
- author:
Adrian - Colyer
- author:
Juergen - Hoeller
- since:
2.0 -
| Method from org.springframework.core.LocalVariableTableParameterNameDiscoverer Detail: |
public String[] getParameterNames(Method method) {
String[] paramNames = (String[]) this.parameterNamesCache.get(method);
if (paramNames == null) {
try {
paramNames = visitMethod(method).getParameterNames();
if (paramNames != null) {
this.parameterNamesCache.put(method, paramNames);
}
}
catch (IOException ex) {
// We couldn't load the class file, which is not fatal as it
// simply means this method of discovering parameter names won't work.
if (logger.isDebugEnabled()) {
logger.debug("IOException whilst attempting to read '.class' file for class [" +
method.getDeclaringClass().getName() +
"] - unable to determine parameter names for method: " + method, ex);
}
}
}
return paramNames;
}
|
public String[] getParameterNames(Constructor ctor) {
String[] paramNames = (String[]) this.parameterNamesCache.get(ctor);
if (paramNames == null) {
try {
paramNames = visitConstructor(ctor).getParameterNames();
if (paramNames != null) {
this.parameterNamesCache.put(ctor, paramNames);
}
}
catch (IOException ex) {
// We couldn't load the class file, which is not fatal as it
// simply means this method of discovering parameter names won't work.
if (logger.isDebugEnabled()) {
logger.debug("IOException whilst attempting to read '.class' file for class [" +
ctor.getDeclaringClass().getName() +
"] - unable to determine parameter names for constructor: " + ctor, ex);
}
}
}
return paramNames;
}
|