Here you can find the source of getAllInterfaces(Class> clazz)
public static final Class<?>[] getAllInterfaces(Class<?> clazz)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.List; public class Main { public static final Class<?>[] getAllInterfaces(Class<?> clazz) { List<Class<?>> allInterfaces = new ArrayList<>(); Class<?> superClass = clazz; while (superClass != null) { Class<?>[] interfaces = superClass.getInterfaces(); if (interfaces != null && interfaces.length > 0) { for (int index = 0; index < interfaces.length; index++) { allInterfaces.add(interfaces[index]); }/* www.java 2 s . c o m*/ } superClass = superClass.getSuperclass(); } return allInterfaces.toArray(new Class<?>[allInterfaces.size()]); } }