Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find if the IType is an abstract class

I have the IType object of a class. I want to know if the class is an abstract class or not. Is there any method available in the IType or ICompilationUnit to determine the same (other than reflection).

like image 501
Krishnaveni Avatar asked Mar 13 '13 06:03

Krishnaveni


2 Answers

IType type = ...;
boolean isAbstract = Flags.isAbstract(type.getFlags());
like image 55
Alexey Romanov Avatar answered Sep 20 '22 10:09

Alexey Romanov


You could get the IType's fully qualified name (maybe using IType.getTypeQualifiedName()), then use Class.forName() on that name to get the Class object, then use the Modifier.isAbstract() as others have recommended.

Java's Class object is part of the reflection suite, so this way still kinda uses reflection...

like image 25
SeKa Avatar answered Sep 21 '22 10:09

SeKa