License: Creative Commons Attribution 3.0 Unported license (CC BY 3.0)
When quoting this document, please refer to the following
DOI: 10.4230/LIPIcs.ECOOP.2019.22
URN: urn:nbn:de:0030-drops-108140
Go to the corresponding LIPIcs Volume Portal

Kang, Hong Jin ; Thung, Ferdian ; Lawall, Julia ; Muller, Gilles ; Jiang, Lingxiao ; Lo, David

Semantic Patches for Java Program Transformation (Experience Report)

LIPIcs-ECOOP-2019-22.pdf (0.5 MB)


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.

BibTeX - Entry

  author =	{Hong Jin Kang and Ferdian Thung and Julia Lawall and Gilles Muller and Lingxiao Jiang and David Lo},
  title =	{{Semantic Patches for Java Program Transformation (Experience Report)}},
  booktitle =	{33rd European Conference on Object-Oriented Programming (ECOOP 2019)},
  pages =	{22:1--22:27},
  series =	{Leibniz International Proceedings in Informatics (LIPIcs)},
  ISBN =	{978-3-95977-111-5},
  ISSN =	{1868-8969},
  year =	{2019},
  volume =	{134},
  editor =	{Alastair F. Donaldson},
  publisher =	{Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik},
  address =	{Dagstuhl, Germany},
  URL =		{},
  URN =		{urn:nbn:de:0030-drops-108140},
  doi =		{10.4230/LIPIcs.ECOOP.2019.22},
  annote =	{Keywords: Program transformation, Java}

Keywords: Program transformation, Java
Collection: 33rd European Conference on Object-Oriented Programming (ECOOP 2019)
Issue Date: 2019
Date of publication: 10.07.2019
Supplementary Material: ECOOP 2019 Artifact Evaluation approved artifact available at; Coccinelle4J can be found at

DROPS-Home | Fulltext Search | Imprint | Privacy Published by LZI