Module DeadCode

Import path

semmle.code.java.deadcode.DeadCode

Imports

Predicates

getADeadRoot

For a dead callable, we identify all the possible dead roots.

hasUsefulBody

A predicate to find non-trivial method implementations. (A trivial implementation is either abstract, or it just throws UnsupportedOperationException or similar.)

isLive

Holds if the given callable has any liveness causes.

possibleLivenessCause

Compute a list of callables such that the liveness of any result would imply the liveness of c.

possibleLivenessCause

Classes

DeadClass

A class is dead if it is from source, and contains no live callables and no live fields. Nested classes make the outer class live if and only if the outer class is considered to be present for namespace purposes only, and the nested class is static.

DeadMethod

A method is dead if it is from source, has no liveness causes, is not a compiler generated method and is not a dead method with a purpose, such as a constructor designed to suppress the default constructor.

DeadRoot

A dead root is not live, and has no liveness causes.

LiveClass

A source class or interface is live if it fulfills one of the following criteria:

NamespaceClass

A namespace class is one that is used purely as a container for static classes, methods and fields.

RootdefCallable
SourceClassOrInterface

A ClassOrInterface type that is from source.

SuppressedConstructor

A constructor that is only declared to override the public accessibility of the default constructor generated by the compiler.

WhitelistedLiveClass

A class which is dead, but should be considered as live.