Standard Analyses

SemmleCode Professional comes with a wide range of pre-packaged analyses, from architectural properties and metrics, to statement-level checks for likely bugs and violations of best practice.


Empty Run in Thread

This query finds thread classes that inherit the empty definition of run() from java.lang.Thread, which does nothing.

How to Interpret the Query Results

The query flags all such classes and displays a list of all detected occurrences in the results view.

How to Address the Query Results

Carefully check the empty thread classes to ensure that they are not a typo.

Source Code
import default

from Class thread, Class emptythread
where thread.hasQualifiedName("java.lang", "Thread") and 
      emptythread.hasSupertype+(thread) and
      not exists(Class middle, Method run | run.hasName("run") and
                                            run.hasModifier("public") and
                                            not run.hasModifier("abstract") and
                                            middle.getAMethod() = run and
                                            middle.hasSupertype+(thread) and
                                            emptythread.hasSupertype*(middle))
select emptythread, "Thread has a useless empty run() inherited from java.lang.Thread."
References