Automatic Refactoring of Java Code Using the Stream API
Autor: | T. F. Valeev, R. A. Ivanov |
---|---|
Rok vydání: | 2019 |
Předmět: | |
Zdroj: | Vestnik NSU. Series: Information Technologies. 17:49-60 |
ISSN: | 2410-0420 1818-7900 |
DOI: | 10.25205/1818-7900-2019-17-2-49-60 |
Popis: | For a long time, functional Java programming was not possible. However, lambda expressions appeared in version 8 of the Java language. Due to the support of standard library classes (Stream, Optional, etc.) in Java, it became possible to describe transformations over data in a functional style. Java is a rather old language with a large imperative code base written in it. In order to take advantage of the new approach, it is necessary to perform a non-trivial refactoring, which can be very tedious and error prone when applied manually. Fortunately, for a sufficiently large number of situations, this refactoring can be safely performed automatically. Using IntelliJ Idea as a platform software tool was developed that allows you to find places where it is possible to automatically convert an imperative code to an equivalent code that uses Stream API, as well as an automatic fix that allows you to make a replacement. Refactoring uses IntelliJ Idea framework to analyze Java code, and integrates into the IDE itself. One of the main criteria for the correct operation of the algorithm is the security of this transformation. The user cannot trust the tool if the transformation can change the semantics of the code. This article discusses various constraints that are imposed on code patterns so that transformation without distortion of semantics is possible. Refactoring has been tested in various libraries to verify the semantics are preserved by checking the test results before and after applying refactoring. This article will not describe the impact of using the Stream API on the performance of the application. |
Databáze: | OpenAIRE |
Externí odkaz: |