Here you can find the source of getInterfaces(Class> c)
public static Class<?>[] getInterfaces(Class<?> c)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static Class<?>[] getInterfaces(Class<?> c) { List<Class<?>> result = new ArrayList<>(); if (c.isInterface()) { result.add(c);//www . java 2s .c o m } else { do { addInterfaces(c, result); c = c.getSuperclass(); } while (c != null); } for (int i = 0; i < result.size(); ++i) { addInterfaces(result.get(i), result); } return result.toArray(new Class<?>[result.size()]); } private static void addInterfaces(Class<?> c, List<Class<?>> list) { for (Class<?> intf : c.getInterfaces()) { if (!list.contains(intf)) { list.add(intf); } } } }