I’d like to check if a Class object represents a subclass of other class for example
Class class1 = Class.forName('Class1'); Class class2 = Class.forName('Class2'); if(class1.isSubClassOf(class2)) // fake methos isSubClassOf { // do sth }
How can I implement this isSubClassOf method ?
Class.isAssignableFrom() provides more-or-less what you’re after, although it handle interfaces also, so may need to do a bit more extra work to be sure that it’s a subclass, direct or otherwise.