SlideShare a Scribd company logo
1 of 21
Download to read offline
Extracting Executable
Transformations from
Distilled Code Changes
Reinout Stevens
resteven@vub.ac.be
@ReinoutStevens
Coen De Roover
cderoove@vub.ac.be
@oniroi
1
Context: Distilled Code Changes
B. Fluri, M. Würsch, M. Pinzger, and H. C. Gall.
Change distilling: Tree differencing for fine-grained source code change extraction.
Transactions on Software Engineering, 2007.
2
1. update(0,1)
2. move(int y = 0;)
3. insert(public int foo()…)
4. delete(int z = 0;)
Output:
00 public class Example {
01 public Integer run(Integer x) {
02 return x;
03 }
04
05 public void test() {
06 int x = 0;
07 int y = 0;
08 int z = 0;
09 run(x);
10 }
11 }
00 public class Example {
01 public Integer run(Integer x) {
02 int y = 0;
03 return x;
04 }
05
06 public int foo() {
07 return 42;
08 }
09
10 public void test() {
11 int x = 1;
12 run(x);
13 }
14 }
Insert
Delete
Move
Update
00 public class Example {
01 public Integer run(Integer x) {
02 return x;
03 }
04
05 public void test() {
06 int x = 0;
07 int y = 0;
08 int z = 0;
09 run(x);
10 }
11 }
00 public class Example {
01 public Integer run(Integer x) {
02 int y = 0;
03 return x;
04 }
05
06 public int foo() {
07 return 42;
08 }
09
10 public void test() {
11 int x = 1;
12 run(x);
13 }
14 }
Revision 1 Revision 2
Goal: Extracting Executable Transformations
3
Insert Insert Move Delete Update Insert Move Delete
Delete Insert Insert Move Insert Delete Update Delete
Update Move Insert Insert Update Update Move …
Naive Approach: Logic Queries over Changes
public class Example {
int x = 0;
}
public class Example {
int y = 0;
}
1. update(“x”, “y”)
1 (defn rename-field [changes]
2 (run* [?update]
3 (member ?update changes)
4 (change|update ?update)
5 (change|update-original ?update ?val|source)
6 (ast :SimpleName ?val|source)
7 (ast-parent ?val|source ?parent|source)
8 (ast :VariableDeclarationFragment ?parent|source)
9 (update-newval ?update ?val|target)
0 (ast :SimpleName ?val|target)
1 (name-name|different ?val|source ?val|target))
4
Revision 1 Revision 2
changes
look for an update
that modifies a field
its name
1. delete(“int x = 0;”)
2. insert(“int aLongerName = 0;”)
1 (defn rename-field [changes]
2 (run* [?insert ?delete]
3 (fresh [?insert|source’ ?delete|original ?i-name ?d-name]
4 (member ?delete changes)
5 (member ?insert changes)
6 (== ?sequence (list ?insert ?delete))
7 (change|insert ?insert)
8 (change|delete ?delete)
9 (insert-node ?insert ?insert|source’)
0 (ast :VariableDeclarationFragment ?insert|source’)
1 (delete-node ?delete ?delete|original)
2 (ast :VariableDeclarationFragment ?delete|source)
3 (has :name ?insert|source’ ?i-name)
4 (has :name ?delete|source ?d-name)
5 (name-name|different ?i-name ?d-name))) 5
public class Example {
int x = 0;
}
public class Example {
int aLongerName = 0;
}
changes
Revision 1 Revision 2
look for a
delete and insert
that introduce a field
and remove a field with
a different name
Naive Approach: Logic Queries over Changes
Problem: Change Equivalence
1. update(“x”, “y”)
1. delete(“int x = 0;”)
2. insert(“int y = 0;”)
1. insert(“int y = 0;”)
2. delete(“int x = 0;”)
Possible 

Changes Sequences
public class Example {
int x = 0;
}
Revision 1
public class Example {
int y = 0;
}
Revision 2
6
One change distiller may produce different change sequences for
the same source code transformation in different commits:
• different change types
• different length
• different subjects of changes
7
Problem: Change Equivalence
or
or
…
Problem Summary
Multiple change sequences implement the same source
code transformation
It is not possible for a user to enumerate all the change
sequences that implement a transformation in a query
8
9
initial state
sought-after state
1 (defn field-rename [esg]
2 (run* [?es]
3 (query-changes esg ?es [?orig-ast ?field]
4 (in-current-es [es ast]
5 (== ?orig-ast ast)
6 (ast-field ast ?field))
7 change->+
8 (in-current-es [es ast]
9 (fresh [?renamed ?new-name]
0 (ast-field ast ?renamed)
1 (ast-field|absent ast ?field)
2 (ast-field|absent ?orig-ast ?renamed)))))
public class Example {
int x = 0;
}
public class Example {
int y = 0;
}
Approach: Before&After AST Specification
10
public class Example {
int x = 0;
int y = 1;
}
public class Example {
}
Source AST Target AST
1 3
2 4
Regular Dependency
List Dependency
Change Dependency Graph
1. insert(int x, Example, Example, nil, :BodyDeclarations, 0)
2. insert(int y, Example, Example, nil, :BodyDeclarations, 1)
3. insert(0, nil, int x, nil, :Initializer, nil)
4. insert(1, nil, int y, nil, :Initializer, nil)
Distilled Change Sequence
public class Example {
}
public class Example {
int x = 0;
int y = 1;
}
public class Example {
int x;
}
public class Example {
int x = 0;
}
public class Example {
int x = 0;
int y;
}
public class Example {
int x;
int y;
}
public class Example {
int x;
int y = 1;
}
public class Example {
int y;
}
public class Example {
int y = 1;
}
1
2
3
2
1
4
2
3 4
1
34
Evolution State Graph
Implementation Overview
11
1 3
2 4
Regular Dependency
List Dependency
1. insert(int x, Example, Example, nil, :BodyDeclarations, 0)
2. insert(int y, Example, Example, nil, :BodyDeclarations, 1)
3. insert(0, nil, int x, nil, :Initializer, nil)
4. insert(1, nil, int y, nil, :Initializer, nil)
Solution: Change Dependency Graph
Insert Dependency List Dependency
Source SourceTarget Target
Move Dependency
Source Target
α
12
Solution: Change Dependency Graph
13
1. insert(int x, Example, Example, nil, :BodyDeclarations, 0)
2. insert(int y, Example, Example, nil, :BodyDeclarations, 1)
3. insert(0, nil, int x, nil, :Initializer, nil)
4. insert(1, nil, int y, nil, :Initializer, nil)
public class Example {
}
public class Example {
int x = 0;
int y = 1;
}
public class Example {
int x;
}
public class Example {
int x = 0;
}
public class Example {
int x = 0;
int y;
}
public class Example {
int x;
int y;
}
public class Example {
int x;
int y = 1;
}
public class Example {
int y;
}
public class Example {
int y = 1;
}
1
2
3
2
1
4
2
3 4
1
34
Solution: Evolution State Graph
• Detect instances of refactorings in open-source
projects using a single evolution query per
refactoring
• Ensure returned change sequences are minimal
and executable
• Compare our approach with the naive approach
K. Prete, N. Rachatasumrit, N. Sudan, and M. Kim,
“Template-based reconstruction of complex refactorings,”
in Proc. of the 2010 Int. Conf. on Software Maintenance (ICSM10)
E. Murphy-Hill, C. Parnin, and A. P. Black,
“How we refactor, and how we know it,”
Transactions on Software Engineering, vol. 38, pp. 5–18, 2012.
14
Evaluation: Outline
15
ChangeNodes
Distiller
Known Refactorings
Magic
Constant
Field
Rename
Unused
Method
public class Example {
}
public class Example {
int x = 0;
int y = 1;
}
public class Example {
int x;
}
public class Example {
int x = 0;
}
public class Example {
int x = 0;
int y;
}
public class Example {
int x;
int y;
}
public class Example {
int x;
int y = 1;
}
public class Example {
int y;
}
public class Example {
int y = 1;
}
1
2
3
2
1
4
2
3 4
1
34
Evolution State Graph
Change Dependency Graph
1 3
2 4
Regular Dependency
List Dependency
Evolution Query
1 (query-changes esg ?es
2 [?absent ?method …]
3 (in-current-es [es ast]
4 (== ast ?absent)
5 (ast-method ast ?method)
6 (child+ ?method ?literal)
7 (literal-value ?literal ?value))
8 change->*
9 (in-current-es [es ast]
0 (ast-ast-field|introduced ?absent ast ?field)
1 (field-value|initialized ?field ?value)
2 (ast-method-method|corresponding …)
3 (child+ ?cmethod ?field-access)
4 (field-name|accessed ?field ?field-access)))
Minimal Executable Code Transformation
Insert Move Insert
Code Rev1
Code Rev2
Insert Move …
Evaluation: Outline
16
1 1 public class Jar extends Zip {
2 2 private static final String INDEX_NAME="META-INF/INDEX.LIST";
3 + private static final String MANIFEST_NAME="META-INF/MANIFEST.MF";
3 4 private Manifest configuredManifest;
4 5 private Manifest savedConfiguredManifest;
5 6
6 7 protected void zipFile( ) throws IOException {
7 - if ("META-INF/MANIFEST.MF".equalsIgnoreCase(vPath)) {
8 + if (MANIFEST_NAME.equalsIgnoreCase(vPath)) {
8 9 if (!doubleFilePass || (doubleFilePass && skipWriting)) {
9 10 filesetManifest(fromArchive,is);
10 11 }
11 12 }
12 13 else {
13 14 super.zipFile(is,zOut,vPath,lastModified,fromArchive,mode);
14 15 }
15 16 }
16 17 }
Evaluation: Replace Magic Constant
17
1 (query-changes esg ?es
2 [?absent ?method ?literal value ?cmethod ?field ?field-access]
3 (in-current-es [es ast]
4 (== ast ?absent)
5 (ast-method ast ?method)
6 (child+ ?method ?literal)
7 (literal-value ?literal ?value))
8 change->*
9 (in-current-es [es ast]
0 (ast-ast-field|introduced ?absent ast ?field)
1 (field-value|initialized ?field ?value)
2 (ast-method-method|corresponding ast ?method ?cmethod)
3 (child+ ?cmethod ?field-access)
4 (field-name|accessed ?field ?field-access)))
protected void zipFile(…) {
if (“META-INF/MANIFEST.MF”
.equalsIgnoreCase(vPath)) {
…
private String MANIFEST_NAME =
“META-INF/MANIFEST.MF";
…
protected void zipFile(…) {
if (MANIFEST_NAME
.equalsIgnoreCase(vPath)) {
…
Evaluation: Replace Magic Constant
18
Legend
insert
delete
move
solution
dependency
update
• Total Changes: 74
• Solution Length Our Approach: 4
• Solution Length Replaying Sequence: 23
Evaluation: Inspecting the Solution
19
Evaluation: Result Summary
NumberofChanges
0
50
100
150
200
250
300
350
Refactoring
Constant Constant Constant Constant Constant Constant Method Method Method Field Field Field Field
6
1513
3
39
12655
10
48
213
24
57
9
264
1214
118
199
1000
23
82
221
27
63
10
291
5
11
25
149
245
1244
74
202
Total Changes Solution Length Replaying Sequence Solution Length Our Approach
Conclusion
• The change equivalence problem renders specifying
a sought-after code transformation in terms of
changes difficult
• Our approach supports specifying code
transformations using before&after states in logic
queries
• Solutions to our queries are a minimal, executable
subsequence of changes that implements the sought-
after transformation
20
Discussion
Do ad-hoc solutions to the change equivalence
problem invalidate existing MSR studies?
21

More Related Content

What's hot

Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia岳華 杜
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL fileRACHIT_GUPTA
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)gekiaruj
 
Coding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean CodeCoding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean CodeGanesh Samarthyam
 
Java Puzzle
Java PuzzleJava Puzzle
Java PuzzleSFilipp
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...Frank Nielsen
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queuesIntro C# Book
 
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...Uehara Junji
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance PuzzlersDoug Hawkins
 
Groovy 1.8の新機能について
Groovy 1.8の新機能についてGroovy 1.8の新機能について
Groovy 1.8の新機能についてUehara Junji
 
Is java8 a true functional programming language
Is java8 a true functional programming languageIs java8 a true functional programming language
Is java8 a true functional programming languageSQLI
 
Is java8a truefunctionallanguage
Is java8a truefunctionallanguageIs java8a truefunctionallanguage
Is java8a truefunctionallanguageSamir Chekkal
 
Easy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEEasy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEUehara Junji
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)mehul patel
 

What's hot (20)

Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL file
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
 
Coding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean CodeCoding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean Code
 
Java Puzzle
Java PuzzleJava Puzzle
Java Puzzle
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 6) A Concise and Practical Introduction to Programming Algorithms in...
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
 
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
 
Class method
Class methodClass method
Class method
 
Groovy 1.8の新機能について
Groovy 1.8の新機能についてGroovy 1.8の新機能について
Groovy 1.8の新機能について
 
Is java8 a true functional programming language
Is java8 a true functional programming languageIs java8 a true functional programming language
Is java8 a true functional programming language
 
Is java8a truefunctionallanguage
Is java8a truefunctionallanguageIs java8a truefunctionallanguage
Is java8a truefunctionallanguage
 
Easy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEEasy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVE
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
Java Generics
Java GenericsJava Generics
Java Generics
 

Similar to Extracting Executable Transformations from Distilled Code Changes

Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Paulo Morgado
 
Functional programming basics
Functional programming basicsFunctional programming basics
Functional programming basicsopenbala
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Codemotion
 
Querying the History of Software Projects using QwalKeko
Querying the History of Software Projects using QwalKekoQuerying the History of Software Projects using QwalKeko
Querying the History of Software Projects using QwalKekostevensreinout
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already KnowKevlin Henney
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)James Titcumb
 
QwalKeko, a History Querying Tool
QwalKeko, a History Querying ToolQwalKeko, a History Querying Tool
QwalKeko, a History Querying Toolstevensreinout
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mark Needham
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)PROIDEA
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8franciscoortin
 
.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir Dresher.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir DresherTamir Dresher
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingAnton Arhipov
 
EdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for JavaEdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for JavaLisa Hua
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisSilvio Cesare
 

Similar to Extracting Executable Transformations from Distilled Code Changes (20)

Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
 
New C# features
New C# featuresNew C# features
New C# features
 
functions
functionsfunctions
functions
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Functional programming basics
Functional programming basicsFunctional programming basics
Functional programming basics
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
 
Querying the History of Software Projects using QwalKeko
Querying the History of Software Projects using QwalKekoQuerying the History of Software Projects using QwalKeko
Querying the History of Software Projects using QwalKeko
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already Know
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
 
ICSM07.ppt
ICSM07.pptICSM07.ppt
ICSM07.ppt
 
QwalKeko, a History Querying Tool
QwalKeko, a History Querying ToolQwalKeko, a History Querying Tool
QwalKeko, a History Querying Tool
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8
 
.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir Dresher.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir Dresher
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
 
EdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for JavaEdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for Java
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 

Recently uploaded

Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...ZurliaSoop
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lodhisaajjda
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfMahamudul Hasan
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...David Celestin
 
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityUnlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityHung Le
 
Zone Chairperson Role and Responsibilities New updated.pptx
Zone Chairperson Role and Responsibilities New updated.pptxZone Chairperson Role and Responsibilities New updated.pptx
Zone Chairperson Role and Responsibilities New updated.pptxlionnarsimharajumjf
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIINhPhngng3
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoKayode Fayemi
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar TrainingKylaCullinane
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfSkillCertProExams
 
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxBEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxthusosetemere
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatmentnswingard
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Baileyhlharris
 
History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathHistory of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathphntsoaki
 
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORNLITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORNtntlai16
 
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESBIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESfuthumetsaneliswa
 
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. MumbaiCall Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. MumbaiPriya Reddy
 
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.Introduction to Artificial intelligence.
Introduction to Artificial intelligence.thamaeteboho94
 

Recently uploaded (20)

Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityUnlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
 
Zone Chairperson Role and Responsibilities New updated.pptx
Zone Chairperson Role and Responsibilities New updated.pptxZone Chairperson Role and Responsibilities New updated.pptx
Zone Chairperson Role and Responsibilities New updated.pptx
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait Cityin kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxBEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathHistory of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth death
 
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORNLITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
 
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESBIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
 
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. MumbaiCall Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
 
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.Introduction to Artificial intelligence.
Introduction to Artificial intelligence.
 

Extracting Executable Transformations from Distilled Code Changes

  • 1. Extracting Executable Transformations from Distilled Code Changes Reinout Stevens resteven@vub.ac.be @ReinoutStevens Coen De Roover cderoove@vub.ac.be @oniroi 1
  • 2. Context: Distilled Code Changes B. Fluri, M. Würsch, M. Pinzger, and H. C. Gall. Change distilling: Tree differencing for fine-grained source code change extraction. Transactions on Software Engineering, 2007. 2 1. update(0,1) 2. move(int y = 0;) 3. insert(public int foo()…) 4. delete(int z = 0;) Output: 00 public class Example { 01 public Integer run(Integer x) { 02 return x; 03 } 04 05 public void test() { 06 int x = 0; 07 int y = 0; 08 int z = 0; 09 run(x); 10 } 11 } 00 public class Example { 01 public Integer run(Integer x) { 02 int y = 0; 03 return x; 04 } 05 06 public int foo() { 07 return 42; 08 } 09 10 public void test() { 11 int x = 1; 12 run(x); 13 } 14 } Insert Delete Move Update 00 public class Example { 01 public Integer run(Integer x) { 02 return x; 03 } 04 05 public void test() { 06 int x = 0; 07 int y = 0; 08 int z = 0; 09 run(x); 10 } 11 } 00 public class Example { 01 public Integer run(Integer x) { 02 int y = 0; 03 return x; 04 } 05 06 public int foo() { 07 return 42; 08 } 09 10 public void test() { 11 int x = 1; 12 run(x); 13 } 14 } Revision 1 Revision 2
  • 3. Goal: Extracting Executable Transformations 3 Insert Insert Move Delete Update Insert Move Delete Delete Insert Insert Move Insert Delete Update Delete Update Move Insert Insert Update Update Move …
  • 4. Naive Approach: Logic Queries over Changes public class Example { int x = 0; } public class Example { int y = 0; } 1. update(“x”, “y”) 1 (defn rename-field [changes] 2 (run* [?update] 3 (member ?update changes) 4 (change|update ?update) 5 (change|update-original ?update ?val|source) 6 (ast :SimpleName ?val|source) 7 (ast-parent ?val|source ?parent|source) 8 (ast :VariableDeclarationFragment ?parent|source) 9 (update-newval ?update ?val|target) 0 (ast :SimpleName ?val|target) 1 (name-name|different ?val|source ?val|target)) 4 Revision 1 Revision 2 changes look for an update that modifies a field its name
  • 5. 1. delete(“int x = 0;”) 2. insert(“int aLongerName = 0;”) 1 (defn rename-field [changes] 2 (run* [?insert ?delete] 3 (fresh [?insert|source’ ?delete|original ?i-name ?d-name] 4 (member ?delete changes) 5 (member ?insert changes) 6 (== ?sequence (list ?insert ?delete)) 7 (change|insert ?insert) 8 (change|delete ?delete) 9 (insert-node ?insert ?insert|source’) 0 (ast :VariableDeclarationFragment ?insert|source’) 1 (delete-node ?delete ?delete|original) 2 (ast :VariableDeclarationFragment ?delete|source) 3 (has :name ?insert|source’ ?i-name) 4 (has :name ?delete|source ?d-name) 5 (name-name|different ?i-name ?d-name))) 5 public class Example { int x = 0; } public class Example { int aLongerName = 0; } changes Revision 1 Revision 2 look for a delete and insert that introduce a field and remove a field with a different name Naive Approach: Logic Queries over Changes
  • 6. Problem: Change Equivalence 1. update(“x”, “y”) 1. delete(“int x = 0;”) 2. insert(“int y = 0;”) 1. insert(“int y = 0;”) 2. delete(“int x = 0;”) Possible Changes Sequences public class Example { int x = 0; } Revision 1 public class Example { int y = 0; } Revision 2 6 One change distiller may produce different change sequences for the same source code transformation in different commits: • different change types • different length • different subjects of changes
  • 8. Problem Summary Multiple change sequences implement the same source code transformation It is not possible for a user to enumerate all the change sequences that implement a transformation in a query 8
  • 9. 9 initial state sought-after state 1 (defn field-rename [esg] 2 (run* [?es] 3 (query-changes esg ?es [?orig-ast ?field] 4 (in-current-es [es ast] 5 (== ?orig-ast ast) 6 (ast-field ast ?field)) 7 change->+ 8 (in-current-es [es ast] 9 (fresh [?renamed ?new-name] 0 (ast-field ast ?renamed) 1 (ast-field|absent ast ?field) 2 (ast-field|absent ?orig-ast ?renamed))))) public class Example { int x = 0; } public class Example { int y = 0; } Approach: Before&After AST Specification
  • 10. 10 public class Example { int x = 0; int y = 1; } public class Example { } Source AST Target AST 1 3 2 4 Regular Dependency List Dependency Change Dependency Graph 1. insert(int x, Example, Example, nil, :BodyDeclarations, 0) 2. insert(int y, Example, Example, nil, :BodyDeclarations, 1) 3. insert(0, nil, int x, nil, :Initializer, nil) 4. insert(1, nil, int y, nil, :Initializer, nil) Distilled Change Sequence public class Example { } public class Example { int x = 0; int y = 1; } public class Example { int x; } public class Example { int x = 0; } public class Example { int x = 0; int y; } public class Example { int x; int y; } public class Example { int x; int y = 1; } public class Example { int y; } public class Example { int y = 1; } 1 2 3 2 1 4 2 3 4 1 34 Evolution State Graph Implementation Overview
  • 11. 11 1 3 2 4 Regular Dependency List Dependency 1. insert(int x, Example, Example, nil, :BodyDeclarations, 0) 2. insert(int y, Example, Example, nil, :BodyDeclarations, 1) 3. insert(0, nil, int x, nil, :Initializer, nil) 4. insert(1, nil, int y, nil, :Initializer, nil) Solution: Change Dependency Graph Insert Dependency List Dependency Source SourceTarget Target Move Dependency Source Target α
  • 13. 13 1. insert(int x, Example, Example, nil, :BodyDeclarations, 0) 2. insert(int y, Example, Example, nil, :BodyDeclarations, 1) 3. insert(0, nil, int x, nil, :Initializer, nil) 4. insert(1, nil, int y, nil, :Initializer, nil) public class Example { } public class Example { int x = 0; int y = 1; } public class Example { int x; } public class Example { int x = 0; } public class Example { int x = 0; int y; } public class Example { int x; int y; } public class Example { int x; int y = 1; } public class Example { int y; } public class Example { int y = 1; } 1 2 3 2 1 4 2 3 4 1 34 Solution: Evolution State Graph
  • 14. • Detect instances of refactorings in open-source projects using a single evolution query per refactoring • Ensure returned change sequences are minimal and executable • Compare our approach with the naive approach K. Prete, N. Rachatasumrit, N. Sudan, and M. Kim, “Template-based reconstruction of complex refactorings,” in Proc. of the 2010 Int. Conf. on Software Maintenance (ICSM10) E. Murphy-Hill, C. Parnin, and A. P. Black, “How we refactor, and how we know it,” Transactions on Software Engineering, vol. 38, pp. 5–18, 2012. 14 Evaluation: Outline
  • 15. 15 ChangeNodes Distiller Known Refactorings Magic Constant Field Rename Unused Method public class Example { } public class Example { int x = 0; int y = 1; } public class Example { int x; } public class Example { int x = 0; } public class Example { int x = 0; int y; } public class Example { int x; int y; } public class Example { int x; int y = 1; } public class Example { int y; } public class Example { int y = 1; } 1 2 3 2 1 4 2 3 4 1 34 Evolution State Graph Change Dependency Graph 1 3 2 4 Regular Dependency List Dependency Evolution Query 1 (query-changes esg ?es 2 [?absent ?method …] 3 (in-current-es [es ast] 4 (== ast ?absent) 5 (ast-method ast ?method) 6 (child+ ?method ?literal) 7 (literal-value ?literal ?value)) 8 change->* 9 (in-current-es [es ast] 0 (ast-ast-field|introduced ?absent ast ?field) 1 (field-value|initialized ?field ?value) 2 (ast-method-method|corresponding …) 3 (child+ ?cmethod ?field-access) 4 (field-name|accessed ?field ?field-access))) Minimal Executable Code Transformation Insert Move Insert Code Rev1 Code Rev2 Insert Move … Evaluation: Outline
  • 16. 16 1 1 public class Jar extends Zip { 2 2 private static final String INDEX_NAME="META-INF/INDEX.LIST"; 3 + private static final String MANIFEST_NAME="META-INF/MANIFEST.MF"; 3 4 private Manifest configuredManifest; 4 5 private Manifest savedConfiguredManifest; 5 6 6 7 protected void zipFile( ) throws IOException { 7 - if ("META-INF/MANIFEST.MF".equalsIgnoreCase(vPath)) { 8 + if (MANIFEST_NAME.equalsIgnoreCase(vPath)) { 8 9 if (!doubleFilePass || (doubleFilePass && skipWriting)) { 9 10 filesetManifest(fromArchive,is); 10 11 } 11 12 } 12 13 else { 13 14 super.zipFile(is,zOut,vPath,lastModified,fromArchive,mode); 14 15 } 15 16 } 16 17 } Evaluation: Replace Magic Constant
  • 17. 17 1 (query-changes esg ?es 2 [?absent ?method ?literal value ?cmethod ?field ?field-access] 3 (in-current-es [es ast] 4 (== ast ?absent) 5 (ast-method ast ?method) 6 (child+ ?method ?literal) 7 (literal-value ?literal ?value)) 8 change->* 9 (in-current-es [es ast] 0 (ast-ast-field|introduced ?absent ast ?field) 1 (field-value|initialized ?field ?value) 2 (ast-method-method|corresponding ast ?method ?cmethod) 3 (child+ ?cmethod ?field-access) 4 (field-name|accessed ?field ?field-access))) protected void zipFile(…) { if (“META-INF/MANIFEST.MF” .equalsIgnoreCase(vPath)) { … private String MANIFEST_NAME = “META-INF/MANIFEST.MF"; … protected void zipFile(…) { if (MANIFEST_NAME .equalsIgnoreCase(vPath)) { … Evaluation: Replace Magic Constant
  • 18. 18 Legend insert delete move solution dependency update • Total Changes: 74 • Solution Length Our Approach: 4 • Solution Length Replaying Sequence: 23 Evaluation: Inspecting the Solution
  • 19. 19 Evaluation: Result Summary NumberofChanges 0 50 100 150 200 250 300 350 Refactoring Constant Constant Constant Constant Constant Constant Method Method Method Field Field Field Field 6 1513 3 39 12655 10 48 213 24 57 9 264 1214 118 199 1000 23 82 221 27 63 10 291 5 11 25 149 245 1244 74 202 Total Changes Solution Length Replaying Sequence Solution Length Our Approach
  • 20. Conclusion • The change equivalence problem renders specifying a sought-after code transformation in terms of changes difficult • Our approach supports specifying code transformations using before&after states in logic queries • Solutions to our queries are a minimal, executable subsequence of changes that implements the sought- after transformation 20
  • 21. Discussion Do ad-hoc solutions to the change equivalence problem invalidate existing MSR studies? 21