SOARES, G. A.; http://lattes.cnpq.br/6215732726947926; SOARES, Gustavo Araújo.
Abstract:
Refactoring is a transformation applied to the program to improve its internal structure without
changing its external behavior. Although it brings benefits, such as making it easier to
maintain the code, it also involves risks, such as introducing compilation errors or behavioral
changes. To help developers in this process, there are refactoring engines. They check conditions
needed to guarantee behavioral preservation, and when these conditions are satisfied,
they apply the desired transformation. However, identifying and implementing the complete
and minimal set of conditions for each refactoring are non-trivial tasks. In practice, tool developers
may not be aware of all conditions. When some condition is not implemented, the
tool may change the program's behavior. On the other hand, they may also implement conditions
that not only prevent behavioral changes, but also prevent behavior-preserving transformations,
reducing the applicability of these tools. In this case, we say they implemented
an overly strong condition. In this work, we propose a technique for automated testing of
Java refactoring engines to identify problems related to missing conditions and overly strong
ones. First, we automatically generate programs to be refactored, as test inputs. To do so,
we propose a Java program generator, JDOLLY, that exhaustively generates programs for a
given scope of Java elements. Then, for each generated program, the desired refactoring is
applied by using the engine under tests. To detect failures in the applied transformations, we
use SAFEREFACTOR, a tool that we proposed for detecting behavioral changes. On the other
hand, when the transformations are rejected by the engine, we propose an differential testing
technique to identify overly strong conditions. It compares the results of the engine under
tests with results of other engines. The final step of the technique is to classify the detected
failures into distinct faults. We evaluated the effectiveness of the technique by testing up to
10 refactorings implemented by three tools: Eclipse 3.7, NetBeans 7.0.1, and two versions of
JastAdd Refactoring Tools (JRRTvl and JRRTv2). Our technique identified 34 faults related
to missing conditions in Eclipse, 51 ones in NetBeans, 24 ones in JRRTvl, and 1 1 ones in
JRRTv2. In addition, it detected 17 and 7 overly strong conditions in Eclipse and JRRTvl,
respectively.