Skip to content

How to retrieve the inheritance classes associated with an abstract class? #894

Closed Answered by JonasKlauke
DeepakUniAdel asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, the comments explain the API.

IdentifierFactory ifac=view.getIdentifierFactory();
//class type
ClassType abstractClass = ifac.getClassType("java.util.AbstractList");
//method signature without the class
MethodSubSignature abstractMethod = ifac.getMethodSubSignature(
  "get",
  ifac.getClassType("java.lang.Object"),
  Collections.singletonList(IntType.getInstance()));

//type hierarchy is needed to get all subtypes
final ViewTypeHierarchy typeHierarchy = new ViewTypeHierarchy(view);
List<Method> implementedMethods=
    //grabs all subtypes
    typeHierarchy.subclassesOf(abstractClass).stream()
        //checks if they have a method object for the requested method
        .map(classType…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@DeepakUniAdel
Comment options

Answer selected by JonasKlauke
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants