public static void dump(Class clazz, Printer printer) {
        printer.start();
        // Dump class header.
        printer.println(String.format("\n**** CLAZZ DUMPER START DUMP OF %s ***", clazz));
        // Dump methods.
        Class<?> searchType = clazz;
        while (searchType != null) {
            Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods());
            for (Method method : methods) {
                printer.println(String.format("METHOD OF CLASS %s: %s ", searchType, method));
            }

            // Dump class fields.
            Field[] fields = searchType.isInterface() ? null : clazz.getDeclaredFields();
            if (fields != null) for (Field field : fields) {
                printer.println(String.format("FIELD OF CLASS %s: %s", searchType, field));
            }

            searchType = searchType.getSuperclass();
        }
        // End.
        printer.println(String.format("**** CLAZZ DUMPER END DUMP OF %s ***\n", clazz));
        printer.end();
    }
Created by Tornaco on 2018/5/1 19:21.
God bless no bug!
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/ClazzDumper.java