||A Combined Pointer and Purity Analysis for Java Programs
|LCS Document Number:
|We present a new method purity analysis for Java programs.
A method is pure if it does not mutate any location that exists in the program state right before method invocation.
Our analysis is built on top of a combined pointer and escape analysis for Java programs and is capable of determining that methods are pure even when the methods do heap
mutation, provided that the mutation affects only objects
created after the beginning of the method.
Because our analysis extracts a precise representation of
the region of the heap that each method may access, it is
able to provide useful information even for methods with
externally visible side eŽects. In particular, it can recognize read-only parameters (a parameter is read-only if the
method does not mutate any objects transitively reachable
from the parameter) and safe parameters (a parameter is
safe if it is read-only and the method does not create any
new externally visible paths in the heap to objects transitively reachable from the parameter). The analysis can also
generate regular expressions that characterize the externally
visible heap locations that the method mutates.
We have implemented our analysis and used it to analyze several data structure implementations. Our results
show that our analysis eŽectively recognize a variety of pure
methods, including pure methods that allocate and mutate
complex auxiliary data structures. Even if the methods are
not pure, our analysis can provide information which may
enable developers to usefully bound the potential side effects
of the method.
|To obtain this publication:
To purchase a printed copy of this publication please contact