A system and method for detecting the mutability of fields and classes in an
arbitrary
program component written in an object oriented programming language is disclosed.
A variable is considered to be mutable if a new value is stored into it, as well
as if any of its reachable variables are mutable. The system and method uses a
static analysis algorithm which can be applied to any software component rather
than whole programs. The analysis classifies fields and classes as either mutable
or immutable. In order to facilitate open-world analysis, the algorithm identifies
situations that expose variables to potential modification by code outside the
component, as well as situations where variables are modified by the analyzed code.
An implementation of the analysis is presented which focuses on detecting mutability
of class variables, so as to avoid isolation problems. The implementation incorporates
intra- and inter-procedural data-flow analyses and is shown to be highly scalable.
Experimental results demonstrate the effectiveness of the algorithms.