Scanning complete class hierarchy

Hi, I’m looking for a way to scan the complete type hierarchy of an examined class. In special, I want to discover if the class or one of its base classes implements java.io.Serializable . I already discovered Custom Java Rule: Retrieve Complete Type Hierarchy . But the link with the mentioned example is broken.

I’m using

        <sonarqube.version>8.9.0.43852</sonarqube.version>
        <sonarjava.version>6.15.1.26025</sonarjava.version>

is there a new valid combination?

Hello @christian.jacob

I updated the broken link in the other post.
In your specific case, I think you could use something like:

ClassTree tree;
// ...
tree.symbol().type().isSubtypeOf("java.io.Serializable");

About the versions, the combination you provided is still the latest one for LTS releases. You could eventually consider to use SonarQube 8.9.7.52159 though. The version of the Java analyzer is unchanged.
If you want to use the latest version of SonarQube, you can go with:

        <sonarqube.version>9.3.0.51899</sonarqube.version>
        <sonarjava.version>7.7.0.28547</sonarjava.version>

Hope this helps.
Quentin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.