Here you can find the source of getParents(final Class> Class)
public static Class<?>[] getParents(final Class<?> Class)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class Main { private static final HashMap<Class<?>, Class<?>[]> cachedClass = new HashMap<Class<?>, Class<?>[]>(); private static final HashMap<Class<?>, HashMap<Class<?>, Class<?>[]>> cachedClassWithDelimiter = new HashMap<Class<?>, HashMap<Class<?>, Class<?>[]>>(); public static Class<?>[] getParents(final Class<?> Class) { return getParents(Class, null); }// w ww. j ava2s . co m public static Class<?>[] getParents(final Class<?> Class, Class<?> delimiter) { HashMap<Class<?>, Class<?>[]> classHash; final Class<?> index; if (delimiter != null) { if ((classHash = cachedClassWithDelimiter.get(Class)) == null) cachedClassWithDelimiter.put(Class, classHash = new HashMap<Class<?>, Class<?>[]>()); index = delimiter; } else { classHash = cachedClass; delimiter = Object.class; index = Class; } Class<?>[] classes; if ((classes = classHash.get(index)) == null) { final List<Class<?>> _classes = new ArrayList<Class<?>>(); Class<?> parent = Class; while ((parent = parent.getSuperclass()) != delimiter && parent != null) _classes.add(parent); classes = _classes.toArray(new Class<?>[_classes.size()]); classHash.put(index, classes); } return classes; } }