Skip to content

Instantly share code, notes, and snippets.

@joubin
Last active February 13, 2016 00:37
Show Gist options
  • Select an option

  • Save joubin/40e361a174af84219262 to your computer and use it in GitHub Desktop.

Select an option

Save joubin/40e361a174af84219262 to your computer and use it in GitHub Desktop.
Get all supers to an object
public static List<String> GetClasses(Class cls) throws ClassNotFoundException {
List<String> clsList = new ArrayList<>();
String name;
while (!(name = cls.getGenericSuperclass().getTypeName()).equals("java.lang.Object")){
clsList.add(name);
cls = Class.forName(name);
}
return clsList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment