Here you can find the source of getClassHierarchy(Object obj, Class> ignoreClass)
public static List<Class<?>> getClassHierarchy(Object obj, Class<?> ignoreClass)
//package com.java2s; // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell import java.util.ArrayList; import java.util.List; public class Main { /** Gets the class hierarchy * /*from w w w. ja va 2s . com*/ * @return List<Class<?>> * * */ public static List<Class<?>> getClassHierarchy(Object obj, Class<?> ignoreClass) { List<Class<?>> ret = new ArrayList<Class<?>>(); if (null != obj) { Class<?> clazz = obj.getClass(); while (null != clazz && (ignoreClass != clazz)) { ret.add(0, clazz); clazz = clazz.getSuperclass(); } } return ret; } }