For my studies as master in computer science, I wrote a thesis titled:
"Refactoring Java with CLP: making existing code generic".
Generics is a new feature in Java 1.5 where types get type parameters. A lot of existing code doesn't use this feature yet. In my thesis I describe a method to automaticly add type parameters to code.
We start from code without type parameters which uses generic classes. Where these generic classes are used, we derive the appropriate type parameter, and add it to the code. In the resulting program types are specified more exact, and we can eliminate many casts. This improves code quality for the programmer, but has no effect on what the code does when executed.
The biggest difference between our system and the existing ones is that we support deriving wildcard types. This leads to better results: we can eliminate more casts, and get more general, reusable code. This is implemented using Constraint Logic Programming (CLP), more specificly CHR.
Some related papers:
Other interesting links:
When doing research related to my thesis, the following bugs were discovered in the Sun Java Compiler: