Here you can find the source of getClassesTree(Class> clazz)
public static List<Class<?>> getClassesTree(Class<?> clazz)
//package com.java2s; /**/*from w w w . ja va 2 s .c om*/ * Aptana Studio * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ import java.util.ArrayList; import java.util.List; public class Main { public static List<Class<?>> getClassesTree(Class<?> clazz) { List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add(clazz); if (clazz.isInterface()) { processInterface(clazz, classes); } else { processClass(clazz, classes); } return classes; } private static void processInterface(Class<?> clazz, List<Class<?>> classes) { Class<?>[] interfaces = clazz.getInterfaces(); for (Class<?> i : interfaces) { if (!classes.contains(i)) { classes.add(i); processInterface(i, classes); } } } private static void processClass(Class<?> clazz, List<Class<?>> classes) { Class<?>[] interfaces = clazz.getInterfaces(); for (Class<?> i : interfaces) { if (!classes.contains(i)) { classes.add(i); processInterface(i, classes); } } Class<?> superClass = clazz.getSuperclass(); if (superClass != null && !classes.contains(superClass)) { classes.add(superClass); processClass(superClass, classes); } } }