Refactoring and Concurrency       


Julian Dolby photoKazuaki Ishizaki<br>(石崎 一明) photo

Refactoring and Concurrency - Relocker

Refactoring Java Programs for Flexible Locking

To be presented at ICSE 2011.

Authors: Max Schfer, Manu Sridharan, Julian Dolby, Frank Tip


Recent versions of the Java standard library offer flexible locking constructs that go beyond the language’s builtin monitor locks in terms of features, and that can be fine-tuned to suit specific application scenarios. Under certain conditions, the use of these locking constructs can improve performance significantly, by reducing lock contention. However, the code transformations needed to convert from one kind of lock to the other are non-trivial, and great care must be taken to update lock usage throughout the program consistently. We present Relocker, an automated tool that assists programmers with refactoring synchronized blocks into ReentrantLocks and ReadWriteLocks, to make exploring the performance tradeoffs associated with different types of locks easier. In experiments on a collection of real-world Java applications, Relocker was able to refactor over 80% of builtin monitors into ReentrantLocks. Additionally, the tool could automatically infer ReadWriteLocks in most cases where programmers had previously introduced them manually.


Source code for the lock performance benchmark: zip

The plugin can be downloaded here. Unzip the archive, then copy all files from subdirectories features and plugins into the corresponding directories of your Eclipse installation, and restart Eclipse. The new refactorings will appear in the Refactoring menu.

The plugin is known to work in Eclipse 3.6 (Helios), on both (64-bit) Linux and MacOS X.

Relocker relies on WALA to do static analysis. The required jar files are included in the distribution. Relocker should work with any WALA version between (at least) 1.1.3 and 1.3.2.