Here you can find the source of getInterfaces(Class clazz)
public static Class[] getInterfaces(Class clazz)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static Class[] getInterfaces(Class clazz) { List interfaces = new ArrayList(); interfaces = getAllInterfacesExclude(clazz, null, interfaces); return (Class[]) (Class[]) interfaces.toArray(new Class[interfaces.size()]); }//w ww . j av a2 s. co m public static Class[] getInterfaces(Class clazz, String excludes[]) { List interfaces = new ArrayList(); interfaces = getAllInterfacesExclude(clazz, excludes, interfaces); return (Class[]) (Class[]) interfaces.toArray(new Class[interfaces.size()]); } private static List getAllInterfacesExclude(Class clazz, String itfNames[], List list) { if (list == null) list = new ArrayList(); if (clazz != null) { Class interfaces[] = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { boolean needAdded = true; if (list.contains(interfaces[i])) continue; if (itfNames != null) { for (int j = 0; j < itfNames.length && needAdded; j++) { if (!interfaces[i].getName().startsWith(itfNames[j])) continue; if (clazz.isInterface()) list.remove(clazz); needAdded = false; } } if (needAdded) { list.add(interfaces[i]); getAllInterfacesExclude(interfaces[i], itfNames, list); } } clazz = clazz.getSuperclass(); getAllInterfacesExclude(clazz, itfNames, list); } return list; } }