Package org.apache.xbean.recipe
Class AsmParameterNameLoader
- java.lang.Object
-
- org.apache.xbean.recipe.AsmParameterNameLoader
-
- All Implemented Interfaces:
ParameterNameLoader
public class AsmParameterNameLoader extends java.lang.Object implements ParameterNameLoader
Implementation of ParameterNameLoader that uses ASM to read the parameter names from the local variable table in the class byte code. This wonderful piece of code was taken from org.springframework.core.LocalVariableTableParameterNameDiscover
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AsmParameterNameLoader.AllParameterNamesDiscoveringVisitor
-
Field Summary
Fields Modifier and Type Field Description private java.util.WeakHashMap<java.lang.reflect.Constructor,java.util.List<java.lang.String>>
constructorCache
Weak map from Constructor to List<String>.private java.util.WeakHashMap<java.lang.reflect.Method,java.util.List<java.lang.String>>
methodCache
Weak map from Method to List<String>.
-
Constructor Summary
Constructors Constructor Description AsmParameterNameLoader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static org.objectweb.asm.ClassReader
createClassReader(java.lang.Class declaringClass)
java.util.List<java.lang.String>
get(java.lang.reflect.Constructor constructor)
Gets the parameter names of the specified constructor or null if the class was compiled without debug symbols on.java.util.List<java.lang.String>
get(java.lang.reflect.Method method)
Gets the parameter names of the specified method or null if the class was compiled without debug symbols on.java.util.Map<java.lang.reflect.Constructor,java.util.List<java.lang.String>>
getAllConstructorParameters(java.lang.Class clazz)
Gets the parameter names of all constructor or null if the class was compiled without debug symbols on.java.util.Map<java.lang.reflect.Method,java.util.List<java.lang.String>>
getAllMethodParameters(java.lang.Class clazz, java.lang.String methodName)
Gets the parameter names of all methods with the specified name or null if the class was compiled without debug symbols on.private java.lang.reflect.Method[]
getMethods(java.lang.Class clazz, java.lang.String methodName)
-
-
-
Field Detail
-
constructorCache
private final java.util.WeakHashMap<java.lang.reflect.Constructor,java.util.List<java.lang.String>> constructorCache
Weak map from Constructor to List<String>.
-
methodCache
private final java.util.WeakHashMap<java.lang.reflect.Method,java.util.List<java.lang.String>> methodCache
Weak map from Method to List<String>.
-
-
Method Detail
-
get
public java.util.List<java.lang.String> get(java.lang.reflect.Method method)
Gets the parameter names of the specified method or null if the class was compiled without debug symbols on.- Specified by:
get
in interfaceParameterNameLoader
- Parameters:
method
- the method for which the parameter names should be retrieved- Returns:
- the parameter names or null if the class was compilesd without debug symbols on
-
get
public java.util.List<java.lang.String> get(java.lang.reflect.Constructor constructor)
Gets the parameter names of the specified constructor or null if the class was compiled without debug symbols on.- Specified by:
get
in interfaceParameterNameLoader
- Parameters:
constructor
- the constructor for which the parameters should be retrieved- Returns:
- the parameter names or null if the class was compiled without debug symbols on
-
getAllConstructorParameters
public java.util.Map<java.lang.reflect.Constructor,java.util.List<java.lang.String>> getAllConstructorParameters(java.lang.Class clazz)
Gets the parameter names of all constructor or null if the class was compiled without debug symbols on.- Parameters:
clazz
- the class for which the constructor parameter names should be retrieved- Returns:
- a map from Constructor object to the parameter names or null if the class was compiled without debug symbols on
-
getAllMethodParameters
public java.util.Map<java.lang.reflect.Method,java.util.List<java.lang.String>> getAllMethodParameters(java.lang.Class clazz, java.lang.String methodName)
Gets the parameter names of all methods with the specified name or null if the class was compiled without debug symbols on.- Parameters:
clazz
- the class for which the method parameter names should be retrievedmethodName
- the of the method for which the parameters should be retrieved- Returns:
- a map from Method object to the parameter names or null if the class was compiled without debug symbols on
-
getMethods
private java.lang.reflect.Method[] getMethods(java.lang.Class clazz, java.lang.String methodName)
-
createClassReader
private static org.objectweb.asm.ClassReader createClassReader(java.lang.Class declaringClass) throws java.io.IOException
- Throws:
java.io.IOException
-
-