Automating Program Transformation for Java Using Semantic Patches

Abstract : Developing software often requires code changes that are widespread and applied to multiple locations. There are tools for Java that allow developers to specify patterns for program matching and source-to-source transformation. However, to our knowledge, none allows for transforming code based on its control-flow context. We prototype Coccinelle4J, an extension to Coccinelle, which is a program transformation tool designed for widespread changes in C code, in order to work on Java source code. We adapt Coccinelle to be able to apply scripts written in the Semantic Patch Language (SmPL), a language provided by Coccinelle, to Java source files. As a case study, we demonstrate the utility of Coccinelle4J with the task of API migration. We show 6 semantic patches to migrate from deprecated Android API methods on several open source Android projects. We describe how SmPL can be used to express several API migrations and justify several of our design decisions.
Complete list of metadatas

Cited literature [7 references]  Display  Hide  Download

https://hal.inria.fr/hal-02023368
Contributor : Julia Lawall <>
Submitted on : Monday, February 18, 2019 - 3:02:22 PM
Last modification on : Friday, July 5, 2019 - 3:26:03 PM
Long-term archiving on : Sunday, May 19, 2019 - 6:41:54 PM

File

RR-9256.pdf
Files produced by the author(s)

Identifiers

  • HAL Id : hal-02023368, version 1

Citation

Hong Jin Kang, Ferdian Thung, Julia Lawall, Gilles Muller, Lingxiao Jiang, et al.. Automating Program Transformation for Java Using Semantic Patches. [Research Report] RR-9256, Inria Paris. 2019. ⟨hal-02023368⟩

Share

Metrics

Record views

154

Files downloads

274