Here you can find the source of getSuperclasses(Class> clazz)
public static List<Class<?>> getSuperclasses(Class<?> clazz)
//package com.java2s; /**/* ww w. j a v a 2s . c o m*/ * $Id: ClassLoaderUtils.java 2 2008-10-01 10:04:26Z azeckoski $ * $URL: http://reflectutils.googlecode.com/svn/trunk/src/main/java/org/azeckoski/reflectutils/ClassLoaderUtils.java $ * ClassLoaderUtils.java - genericdao - May 8, 2008 5:39:34 PM - azeckoski ************************************************************************** * Copyright (c) 2008 Aaron Zeckoski * Licensed under the Apache License, Version 2.0 * * A copy of the Apache License has been included in this * distribution and is available at: http://www.apache.org/licenses/LICENSE-2.0.txt * * Aaron Zeckoski (azeckoski@gmail.com) (aaronz@vt.edu) (aaron@caret.cam.ac.uk) */ import java.util.ArrayList; import java.util.List; public class Main { /** * Returns a list of all superclasses and implemented interfaces by the supplied class, * recursively to the base, up to but excluding Object.class. These will be listed in order from * the supplied class, all concrete superclasses in ascending order, and then finally all * interfaces in recursive ascending order.<br/> * This will include duplicates if any superclasses implement the same classes * * Taken from PonderUtilCore around version 1.2.2 * - Antranig Basman (antranig@caret.cam.ac.uk) */ public static List<Class<?>> getSuperclasses(Class<?> clazz) { List<Class<?>> accumulate = new ArrayList<Class<?>>(); while (clazz != Object.class) { accumulate.add(clazz); clazz = clazz.getSuperclass(); } int supers = accumulate.size(); for (int i = 0; i < supers; ++i) { appendSuperclasses(accumulate.get(i), accumulate); } return accumulate; } /** * Taken from PonderUtilCore around version 1.2.2 * - Antranig Basman (antranig@caret.cam.ac.uk) */ private static void appendSuperclasses(Class<?> clazz, List<Class<?>> accrete) { Class<?>[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { accrete.add(interfaces[i]); } for (int i = 0; i < interfaces.length; ++i) { appendSuperclasses(interfaces[i], accrete); } } }