A very basic analysis which identifies those classes that can never be instantiated (e.g.,
java.lang.Math).
A class is not (potentially) instantiable if:
it only defines private constructors and these constructors are not called
by any static method and the class is also not Serializable.
Note
A more precise analysis is available that uses the fixpoint computations framework.
,
The analysis does not take reflective instantiations into account!
,
If this class is queried (after performing the analysis) about a class that
was not analyzed, the result will be that the class is considered to be
instantiable.
This information is relevant in various contexts, e.g., to determine a
precise call graph. For example, instance methods of those objects that cannot be
created are always dead.
val instantiableClasses = project.get(InstantiableClassesKey)
,
This analysis does not consider protected and/or package visible constructors as
it assumes that classes may be added to the respective package later on (open-packages
assumption.)
A very basic analysis which identifies those classes that can never be instantiated (e.g.,
java.lang.Math
).A class is not (potentially) instantiable if:
A more precise analysis is available that uses the fixpoint computations framework.
,The analysis does not take reflective instantiations into account!
,If this class is queried (after performing the analysis) about a class that was not analyzed, the result will be that the class is considered to be instantiable. This information is relevant in various contexts, e.g., to determine a precise call graph. For example, instance methods of those objects that cannot be created are always dead.
Usage
Use the InstantiableClassesKey to query a project about the instantiable classes.
val instantiableClasses = project.get(InstantiableClassesKey)
,This analysis does not consider protected and/or package visible constructors as it assumes that classes may be added to the respective package later on (open-packages assumption.)