public static String[] getMethodVariableNames(final Class<?> clazz, final String targetMethodName, final Class<?>[] types) {
        CtClass cc;
        CtMethod cm = null;

        try {
            if (null == CLASS_POOL.find(clazz.getName())) {
                CLASS_POOL.insertClassPath(new ClassClassPath(clazz));
            }

            cc = CLASS_POOL.get(clazz.getName());
            final CtClass[] ptypes = new CtClass[types.length];

            for (int i = 0; i < ptypes.length; i++) {
                ptypes[i] = CLASS_POOL.get(types[i].getName());
            }
            cm = cc.getDeclaredMethod(targetMethodName, ptypes);
        } catch (final NotFoundException e) {
            LOGGER.log(Level.ERROR, "Get method variable names failed", e);
        }

        if (null == cm) {
            return new String[types.length];
        }

        final MethodInfo methodInfo = cm.getMethodInfo();
        final CodeAttribute codeAttribute = methodInfo.getCodeAttribute();
        final LocalVariableAttribute attr = (LocalVariableAttribute) codeAttribute.getAttribute(LocalVariableAttribute.tag);
        String[] variableNames = new String[0];

        try {
            variableNames = new String[cm.getParameterTypes().length];
        } catch (final NotFoundException e) {
            LOGGER.log(Level.ERROR, "Get method variable names failed", e);
        }

        // final int staticIndex = Modifier.isStatic(cm.getModifiers()) ? 0 : 1;
        int j = -1;
        String variableName = null;
        Boolean ifkill = false;

        while (!"this".equals(variableName)) {
            j++;
            variableName = attr.variableName(j);
            // to prevent heap error when there being some unknown reasons to resolve the VariableNames
            if (j > 99) {
                LOGGER.log(Level.WARN,
                        "Maybe resolve to VariableNames error [class=" + clazz.getName() + ", targetMethodName=" + targetMethodName + ']');
                ifkill = true;
                break;
            }
        }

        if (!ifkill) {
            for (int i = 0; i < variableNames.length; i++) {
                variableNames[i] = attr.variableName(++j);
            }
        }
        return variableNames;
    }
public static String [ ] getMethodVariableNames ( final Class < ? > clazz , final String targetMethodName , final Class < ? > [ ] types ) { CtClass cc ; CtMethod cm = null ; try { if ( null == CLASS_POOL . find ( clazz . getName ( ) ) ) { CLASS_POOL . insertClassPath ( new ClassClassPath ( clazz ) ) ; } cc = CLASS_POOL . get ( clazz . getName ( ) ) ; final CtClass [ ] ptypes = new CtClass [ types . length ] ; for ( int i = 0 ; i < ptypes . length ; i ++ ) { ptypes [ i ] = CLASS_POOL . get ( types [ i ] . getName ( ) ) ; } cm = cc . getDeclaredMethod ( targetMethodName , ptypes ) ; } catch ( final NotFoundException e ) { LOGGER . log ( Level . ERROR , "Get method variable names failed" , e ) ; } if ( null == cm ) { return new String [ types . length ] ; } final MethodInfo methodInfo = cm . getMethodInfo ( ) ; final CodeAttribute codeAttribute = methodInfo . getCodeAttribute ( ) ; final LocalVariableAttribute attr = ( LocalVariableAttribute ) codeAttribute . getAttribute ( LocalVariableAttribute . tag ) ; String [ ] variableNames = new String [ 0 ] ; try { variableNames = new String [ cm . getParameterTypes ( ) . length ] ; } catch ( final NotFoundException e ) { LOGGER . log ( Level . ERROR , "Get method variable names failed" , e ) ; } int j = - 1 ; String variableName = null ; Boolean ifkill = false ; while ( ! "this" . equals ( variableName ) ) { j ++ ; variableName = attr . variableName ( j ) ; if ( j > 99 ) { LOGGER . log ( Level . WARN , "Maybe resolve to VariableNames error [class=" + clazz . getName ( ) + ", targetMethodName=" + targetMethodName + ']' ) ; ifkill = true ; break ; } } if ( ! ifkill ) { for ( int i = 0 ; i < variableNames . length ; i ++ ) { variableNames [ i ] = attr . variableName ( ++ j ) ; } } return variableNames ; }
Get method variable names of the specified class, target method name and parameter types.

@param clazz            the specific clazz
@param targetMethodName the specified target method name
@param types            the specified parameter types
@return the String[] of names