反射机制在tomcat中的运用

来源:互联网 发布:商城源码怎么去后门 编辑:程序博客网 时间:2024/05/18 01:39



反射机制这个概念大家可以百度去看哈


直接贴代码


    private static Method[] getAllDeclaredMethods(Class c) {        if (c.equals(javax.servlet.http.HttpServlet.class)) {            return null;        }        //获取父类的方法(相当于递归调用)        Method[] parentMethods = getAllDeclaredMethods(c.getSuperclass());        Method[] thisMethods = c.getDeclaredMethods();                if ((parentMethods != null) && (parentMethods.length > 0)) {            Method[] allMethods =                new Method[parentMethods.length + thisMethods.length];            System.arraycopy(parentMethods, 0, allMethods, 0,                             parentMethods.length);            System.arraycopy(thisMethods, 0, allMethods, parentMethods.length,                             thisMethods.length);            thisMethods = allMethods;        }        return thisMethods;    }


0 0