public static String [ ] getMethodParamNames ( final Method m ) { if ( METHOD_NAMES_POOL . containsKey ( m ) ) return METHOD_NAMES_POOL . get ( m ) ; final String [ ] paramNames = new String [ m . getParameterTypes ( ) . length ] ; final String n = m . getDeclaringClass ( ) . getName ( ) ; ClassReader cr ; try { cr = new ClassReader ( n ) ; } catch ( IOException e ) { return null ; } cr . accept ( new ClassVisitor ( Opcodes . ASM5 ) { @ Override public MethodVisitor visitMethod ( final int access , final String name , final String desc , final String signature , final String [ ] exceptions ) { final Type [ ] args = Type . getArgumentTypes ( desc ) ; // The method name is the same and the number of parameters is the same if ( ! name . equals ( m . getName ( ) ) || ! sameType ( args , m . getParameterTypes ( ) ) ) { return super . visitMethod ( access , name , desc , signature , exceptions ) ; } MethodVisitor v = super . visitMethod ( access , name , desc , signature , exceptions ) ; return new MethodVisitor ( Opcodes . ASM5 , v ) { @ Override public void visitLocalVariable ( String name , String desc , String signature , Label start , Label end , int index ) { int i = index - 1 ; // if it is a static method, the first is the parameter // if it's not a static method, the first one is "this" and then the parameter of the method if ( Modifier . isStatic ( m . getModifiers ( ) ) ) { i = index ; } if ( i >= 0 && i < paramNames . length ) { paramNames [ i ] = name ; } super . visitLocalVariable ( name , desc , signature , start , end , index ) ; } } ; } } , 0 ) ; METHOD_NAMES_POOL . put ( m , paramNames ) ; return paramNames ; }
get method param names