SlideShare a Scribd company logo
1 of 31
Download to read offline
JAVADIFF
JAVA CODE DIFF TOOL
GUERRERA ALESSANDRO - MICCO ENRICO
ASSOCIATE PROFESSOR MASSIMILIANO DI PENTA
SOFTWARE ENGINEERING COURSE
UNIVERSITY OF SANNIO
BACKGROUND
Diff utility: developed in the early 1970s on the Unix operating
system
• File comparison utility that outputs the differences between two
files
• Finds changes made per line for text files
• Longest common subsequence problem (LCS)
Only textual differences
1/15/2014Software Engineering Course 2
OBJECTIVES
• Create a Java semantic diff utility
• Find semantic differences between 2 versions of the same java
file
• Textual layout independent
• Calculate a diff factor
Identify structural changes made in a new version of a Java file
1/15/2014Software Engineering Course 3
GOALS
• Comparison
• Java source file converted in XML format
• Modeling objects from XML files
• Diff algorithms on crated objects
• Comparison criteria
• Classes: Specifiers, Package, Import, Name, Superclass, Interfaces,
Attributes, Methods
• Methods: Name, Return Type, Specifiers, Exceptions, Parameters,
Statements
• Attributes: Name, Type, Specifiers
• Output: XML diff report
1/15/2014Software Engineering Course 4
ANALYSIS TYPES
Types of analysis:
1. Class analysis: specified a first file class name, are calculated differences
with all classes of the second file
2. Attributes analysis: specified the attribute name and class membership,
are calculated differences with attributes of the second file into the same
class
3. Methods analysis: specified the method name and class membership, are
calculated differences with methods of the second file into the same class
4. Quick analysis: are compared all classes of two files and are evaluated
differences as numbers of added or removed elements
5. Detailed analysis: are compared all classes of two files and are evaluated
differences as numbers of added or removed elements, considering also
modified elements
6. Full analysis: analysis on all elements, like attributes and methods.
1/15/2014Software Engineering Course 5
COMMAND LINE USAGE
User can interacts with the tool using command line instructions
javadiff [OPTIONS]... file1.java file2.java
Options:
• -c class, --classes class: perform a full comparison between classes in FILES
• -a class attribute, --attributes class attribute: perform a full comparison between attributes in FILES
• -m class method, --methods class method: perform a full comparison between methods in FILES
• -q, --quick: perform a quick comparison between FILES
• -d, --detailed: perform a detailed comparison between FILES
• -f, --full: perform a full comparison between FILES
• -h, --help: display this help and exit
• -v, --version: output version information and exit
1/15/2014Software Engineering Course 6
USE CASES
Name Description
1 Attributes Diff Perform attributes analysis
2 Methods Diff Perform methods analysis
3 Classes Diff Perform classes analysis
4 Quick Diff Perform quick analysis
5 Detailed Diff Perform detailed analysis
6 Full Diff Perform full analysis
7 Show Help Show software manual
8 Show Version Show software version
1/15/2014Software Engineering Course 7
SOME USE CASES
Name Classes Diff
Description System usage for classes diff analysis
Actors Max, System
Input -c parameter, class name, 2 files
Pre-condition Files must contain Java source code
Output XML report generated from System
Post-condition
Main scenario 1. Max uses System from cli with inputs
2. System runs classes diff, generates output and exit
Alternative scenario 2a. System show an error message and exit
1/15/2014Software Engineering Course 8
SOME USE CASES
Name Full Diff
Description System usage for full diff analysis
Actors Max, System
Input -f parameter, 2 files
Pre-condition Files must contain Java source code
Output XML report generated from System
Post-condition
Main scenario 1. Max uses System from cli with inputs
2. System runs full diff, generates output and exit
Alternative scenario 2a. System show an error message and exit
1/15/2014Software Engineering Course 9
USE CASES DIAGRAM
1/15/2014Software Engineering Course 10
srcML: document-oriented XML representation of source code
• Tool included in JavaDiff to convert java source file into XML
documents
• Combination of source code (text) and AST information (tags)
• Simplified management of files content
• Java structures easily identifiable
SRCML TOOLKIT
1/15/2014Software Engineering Course
Class
Main
{
//…
}
<?xml
version
…
</>
Java Code srcML file
11
JAVADIFF TOOL
1/15/2014Software Engineering Course
Class
Main
{
//…
}
Java Code
Class
Main
{
//…
}
Java Code
<?xml
version
…
</>
XML report
<?xml
version
…
</>
srcML file
<?xml
version
…
</>
srcML file
12
JAVADIFF EXAMPLE
1/15/2014Software Engineering Course 13
…
public double sum
(double a, double b)
{
double result=a+b;
return result;
}
…
…
public int sum (double
a, double b)
{
int result=a+b;
return result;
}
…
<Description>
Differences between
methods "sum" and
"sum" in class
"Calculator“
</Description>
<DiffFactor>
30.0
</DiffFactor>
<DiffResult>
Same name
- Type:
double modified
in int
- statements
DECL_STMT double
result = a + b;
modified in:
DECL_STMT int
result = a + b;
</DiffResult>
Java Code
Java Code
XML Report
SYSTEM ARCHITECTURE
1/15/2014Software Engineering Course 14
SUBSYSTEM DECOMPOSITION
1/15/2014Software Engineering Course 15
PACKAGE DIAGRAM
1/15/2014Software Engineering Course 16
CLASS DIAGRAMS
• JavaDiffApplication
• CommandParser
• ConsolePrinter
• Src2SrcmlLauncher
• OsSelector
• JavaDiffCore
• ReportPrinter
• ObjectMarshaller
• Description:
• Represent javaDiff components
1/15/2014Software Engineering Course 17
CLASS DIAGRAMS
• SrcmlModel
• SrcmlClass
• SrcmlAttribute
• SrcmlMethod
• Parameter
• Statement
• Description:
• Object representation for XML file
generated with srcML tool
1/15/2014Software Engineering Course 18
CLASS DIAGRAMS
• DiffModel
• DiffElement
• DiffClassElement
• DiffAttributeElement
• DiffMethodElement
• Description:
• Contains elementary
differences between srcML
models
• Added elements
• Removed elements
1/15/2014Software Engineering Course 19
CLASS DIAGRAMS
• DiffReport
• DiffReportElement
• DiffElement
• DiffClassElement
• DiffAttributeElement
• DiffMethodElement
• Description:
• Contains DiffElements with:
• Elements info
• Numeric difference factor
• Details about differences between
elements (class, attribute, method)
1/15/2014Software Engineering Course 20
TECHNOLOGIES
• Eclipse IDE (Juno SR1) for Java
• Subversive (1.1.0):
• Subversion (SVN) team provider
• Eclipse plug-in
• srcML (Trunk 13990 – 07 Jun 2012):
• document-oriented XML representation of source code
• Platform-dependent binaries integrated with Java’s ProcessBuilder
• jDOM (2.0.4):
• Java-based solution for accessing, manipulating, and outputting XML data from
Java
1/15/2014Software Engineering Course 21
SOFTWARE TESTING
• Software Lifecycle Activity which is aimed for evaluating quality of a program
and also for improving it
• Process of verifying and validating that a software application or program
• meets the business and technical requirements, that guided its design and development
and works as expected
• Identifies important errors
• Other software quality factors:
• Reliability
• Performance
• Security
• Maintainability
• …
1/15/2014Software Engineering Course 22
• Functional Testing (Black-Box)
• Checks conformance with specifications
• Helps categorize inputs and derive expected outputs
• Helps test case generation and test oracles
• Our approach: Category-Partition Testing
• The system is divided into individual “functions” that can be
independently tested
• The method identifies the parameters of each “function” and, for
each parameter, identifies distinct categories
• Allowable combinations of choices in the categories are
converted in test data and test cases are generated
TESTING APPROACH
1/15/2014Software Engineering Course 23
• JavaDiff functions:
Function Parameters
1 Attributes Diff –a “ClassName” “AttributeName” file1 file2
2 Methods Diff –m “ClassName” “MethodName” file1 file2
3 Classes Diff –c “ClassName” file1 file2
4 Quick Diff –q file1 file2 (also only file1 file2)
5 Detailed Diff -d file1 file2
6 Full Diff -f file1 file2
7 Show Help -h (also no parameters)
8 Show Version -v
TESTING APPROACH
1/15/2014Software Engineering Course 24
• Diff categories for (file1, file2) parameters in [1, 6]
functions:
1. addedAttributes
2. addedClass
3. addedClassExtends
4. addedClassImports
5. addedClassInterfaces
6. addedClassSpecifiers
7. addedMethods
8. modifiedAttributes
9. modifiedClassExtends
10. modifiedClassImports
11. modifiedClassInterfaces
12. modifiedClassSpecifiers
13. modifiedMethods
14. modifiedPackage
15. removedAttributes
16. removedClass
17. removedClassExtends
18. removedClassImports
19. removedClassInterfaces
20. removedClassSpecifiers
21. removedMethods
22. removedPackage
23. renamedAttributes
24. renamedClass
25. renamedMethods
TESTING APPROACH
1/15/2014Software Engineering Course 25
• Other categories for (file1, file2) parameters in [4-6]
functions:
• GitHub1
• Github2
• Some other categories for parameters:
• Input options error
• Too many input options error
• File path error (File not found)
• System exceptions
TESTING APPROACH
1/15/2014Software Engineering Course 26
• Formal written test case:
• Known input (Test Data)
• Expected output, worked out before the test is executed
• Automated test case generation with JUnit:
• Open source framework used for writing & running tests
• Test suites:
1. AttributesDiff Test Suite
2. Methods Diff Test Suite
3. Classes Diff Test Suite
4. Quick Diff Test Suite
5. Detailed Diff Test Suite
6. Full Diff Test Suite
7. Help Test Suite
8. Version Test Suite
9. Github Test Suite
10. Error Test Suite
TEST CASES SPECIFICATION
1/15/2014Software Engineering Course 27
• Attributes Diff function:
Test Case testAttributesDiff()
Test Description "Attributes Diff" funtion testing
Class’ attribute comparison between (file1, file2)
sources
Actors
Involved Classes JavaDiffApplication
Preconditions
Test Inputs (Data) String[] args = {"-a", "Calculator", "mem", file1, file2};
Expected Outputs Report identical to test oracle’s report
Test Outputs Report
Test Result Success
Error Description
Notes This Test Case was run for all 25 categories of (file1,
file2) parameters
TEST CASES
1/15/2014Software Engineering Course 28
• Full Diff function:
Test Case testFullDiff()
Test Description "Full Diff" funtion testing
Full comparison between (file1, file2) sources
Actors
Involved Classes JavaDiffApplication
Preconditions
Test Inputs (Data) String[] args = {"-f", file1, file2};
Expected Outputs Report identical to test oracle’s report
Test Outputs Report
Test Result Success
Error Description
Notes This Test Case was run for all 25 categories of (file1,
file2) parameters
TEST CASES
1/15/2014Software Engineering Course 29
• Functional test coverage:
• Test cases must cover system specifications
• Code coverage:
• measure used to describe the degree to which the source code is tested by test suites
• EclEmma:
• free Java code coverage tool for Eclipse
• Coverage data can be exported in HTML, XML or CSV format
• Testing results:
• Covered Instructions: 98.4 %
• Covered branches: 84.6%
1/15/2014Software Engineering Course 30
CODE COVERAGE
THANKS!
1/15/2014Software Engineering Course 31

More Related Content

What's hot

Java Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY DucatJava Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY DucatShri Prakash Pandey
 
Presentation of the Instance Model Bus
Presentation of the Instance Model BusPresentation of the Instance Model Bus
Presentation of the Instance Model Busjccastrejon
 
MexADL - HADAS Presentation
MexADL - HADAS PresentationMexADL - HADAS Presentation
MexADL - HADAS Presentationjccastrejon
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Sandeep Rawat
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basicsthe_wumberlog
 
Opal Hermes - towards representative benchmarks
Opal  Hermes - towards representative benchmarksOpal  Hermes - towards representative benchmarks
Opal Hermes - towards representative benchmarksMichaelEichberg1
 
Java programming language
Java programming languageJava programming language
Java programming languageSubhashKumar329
 
Model2Roo - ACME
Model2Roo - ACMEModel2Roo - ACME
Model2Roo - ACMEjccastrejon
 
Extending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective LanguagesExtending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective Languagesfranciscoortin
 
UML Case Tools
UML Case ToolsUML Case Tools
UML Case ToolsAshesh R
 
02.egovFrame Development Environment training book
02.egovFrame Development Environment training book02.egovFrame Development Environment training book
02.egovFrame Development Environment training bookChuong Nguyen
 
Core java kvr - satya
Core  java kvr - satyaCore  java kvr - satya
Core java kvr - satyaSatya Johnny
 
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Shinpei Hayashi
 

What's hot (20)

Java Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY DucatJava Training in Noida Delhi NCR BY Ducat
Java Training in Noida Delhi NCR BY Ducat
 
Java
JavaJava
Java
 
Presentation of the Instance Model Bus
Presentation of the Instance Model BusPresentation of the Instance Model Bus
Presentation of the Instance Model Bus
 
MexADL - HADAS Presentation
MexADL - HADAS PresentationMexADL - HADAS Presentation
MexADL - HADAS Presentation
 
Java Programming Fundamentals
Java Programming Fundamentals Java Programming Fundamentals
Java Programming Fundamentals
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basics
 
Opal Hermes - towards representative benchmarks
Opal  Hermes - towards representative benchmarksOpal  Hermes - towards representative benchmarks
Opal Hermes - towards representative benchmarks
 
Java programming language
Java programming languageJava programming language
Java programming language
 
Ppt chapter02
Ppt chapter02Ppt chapter02
Ppt chapter02
 
Model2Roo - ACME
Model2Roo - ACMEModel2Roo - ACME
Model2Roo - ACME
 
Java swing 1
Java swing 1Java swing 1
Java swing 1
 
Add on packages
Add on packagesAdd on packages
Add on packages
 
Extending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective LanguagesExtending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective Languages
 
UML Case Tools
UML Case ToolsUML Case Tools
UML Case Tools
 
Introduction to java programming part 2
Introduction to java programming  part 2Introduction to java programming  part 2
Introduction to java programming part 2
 
02.egovFrame Development Environment training book
02.egovFrame Development Environment training book02.egovFrame Development Environment training book
02.egovFrame Development Environment training book
 
C progrmming
C progrmmingC progrmming
C progrmming
 
Core java kvr - satya
Core  java kvr - satyaCore  java kvr - satya
Core java kvr - satya
 
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
 

Similar to JavaDiff - Java source code diff tool

AADL: Architecture Analysis and Design Language
AADL: Architecture Analysis and Design LanguageAADL: Architecture Analysis and Design Language
AADL: Architecture Analysis and Design LanguageIvano Malavolta
 
ESSIR LivingKnowledge DiversityEngine tutorial
ESSIR LivingKnowledge DiversityEngine tutorialESSIR LivingKnowledge DiversityEngine tutorial
ESSIR LivingKnowledge DiversityEngine tutorialJonathon Hare
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cfloraaluoch3
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docxhoney725342
 
Devoxx Belgium 2015
Devoxx Belgium 2015Devoxx Belgium 2015
Devoxx Belgium 2015GiedriusTS
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015Oro Inc.
 
Example Of Import Java
Example Of Import JavaExample Of Import Java
Example Of Import JavaMelody Rios
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpikeos890
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
 
java tutorial for beginner - Free Download
java tutorial for beginner - Free Downloadjava tutorial for beginner - Free Download
java tutorial for beginner - Free DownloadTIB Academy
 
A Journey through the JDKs (Java 9 to Java 11)
A Journey through the JDKs (Java 9 to Java 11)A Journey through the JDKs (Java 9 to Java 11)
A Journey through the JDKs (Java 9 to Java 11)Markus Günther
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptxLadduAnanu
 

Similar to JavaDiff - Java source code diff tool (20)

AADL: Architecture Analysis and Design Language
AADL: Architecture Analysis and Design LanguageAADL: Architecture Analysis and Design Language
AADL: Architecture Analysis and Design Language
 
ESSIR LivingKnowledge DiversityEngine tutorial
ESSIR LivingKnowledge DiversityEngine tutorialESSIR LivingKnowledge DiversityEngine tutorial
ESSIR LivingKnowledge DiversityEngine tutorial
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in c
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docx
 
Devoxx Belgium 2015
Devoxx Belgium 2015Devoxx Belgium 2015
Devoxx Belgium 2015
 
Sw Software Design
Sw Software DesignSw Software Design
Sw Software Design
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015
 
Example Of Import Java
Example Of Import JavaExample Of Import Java
Example Of Import Java
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
SDLC
SDLCSDLC
SDLC
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
java tutorial for beginner - Free Download
java tutorial for beginner - Free Downloadjava tutorial for beginner - Free Download
java tutorial for beginner - Free Download
 
MDE in Practice
MDE in PracticeMDE in Practice
MDE in Practice
 
A Journey through the JDKs (Java 9 to Java 11)
A Journey through the JDKs (Java 9 to Java 11)A Journey through the JDKs (Java 9 to Java 11)
A Journey through the JDKs (Java 9 to Java 11)
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptx
 
Csci360 20 (1)
Csci360 20 (1)Csci360 20 (1)
Csci360 20 (1)
 
Csci360 20
Csci360 20Csci360 20
Csci360 20
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

JavaDiff - Java source code diff tool

  • 1. JAVADIFF JAVA CODE DIFF TOOL GUERRERA ALESSANDRO - MICCO ENRICO ASSOCIATE PROFESSOR MASSIMILIANO DI PENTA SOFTWARE ENGINEERING COURSE UNIVERSITY OF SANNIO
  • 2. BACKGROUND Diff utility: developed in the early 1970s on the Unix operating system • File comparison utility that outputs the differences between two files • Finds changes made per line for text files • Longest common subsequence problem (LCS) Only textual differences 1/15/2014Software Engineering Course 2
  • 3. OBJECTIVES • Create a Java semantic diff utility • Find semantic differences between 2 versions of the same java file • Textual layout independent • Calculate a diff factor Identify structural changes made in a new version of a Java file 1/15/2014Software Engineering Course 3
  • 4. GOALS • Comparison • Java source file converted in XML format • Modeling objects from XML files • Diff algorithms on crated objects • Comparison criteria • Classes: Specifiers, Package, Import, Name, Superclass, Interfaces, Attributes, Methods • Methods: Name, Return Type, Specifiers, Exceptions, Parameters, Statements • Attributes: Name, Type, Specifiers • Output: XML diff report 1/15/2014Software Engineering Course 4
  • 5. ANALYSIS TYPES Types of analysis: 1. Class analysis: specified a first file class name, are calculated differences with all classes of the second file 2. Attributes analysis: specified the attribute name and class membership, are calculated differences with attributes of the second file into the same class 3. Methods analysis: specified the method name and class membership, are calculated differences with methods of the second file into the same class 4. Quick analysis: are compared all classes of two files and are evaluated differences as numbers of added or removed elements 5. Detailed analysis: are compared all classes of two files and are evaluated differences as numbers of added or removed elements, considering also modified elements 6. Full analysis: analysis on all elements, like attributes and methods. 1/15/2014Software Engineering Course 5
  • 6. COMMAND LINE USAGE User can interacts with the tool using command line instructions javadiff [OPTIONS]... file1.java file2.java Options: • -c class, --classes class: perform a full comparison between classes in FILES • -a class attribute, --attributes class attribute: perform a full comparison between attributes in FILES • -m class method, --methods class method: perform a full comparison between methods in FILES • -q, --quick: perform a quick comparison between FILES • -d, --detailed: perform a detailed comparison between FILES • -f, --full: perform a full comparison between FILES • -h, --help: display this help and exit • -v, --version: output version information and exit 1/15/2014Software Engineering Course 6
  • 7. USE CASES Name Description 1 Attributes Diff Perform attributes analysis 2 Methods Diff Perform methods analysis 3 Classes Diff Perform classes analysis 4 Quick Diff Perform quick analysis 5 Detailed Diff Perform detailed analysis 6 Full Diff Perform full analysis 7 Show Help Show software manual 8 Show Version Show software version 1/15/2014Software Engineering Course 7
  • 8. SOME USE CASES Name Classes Diff Description System usage for classes diff analysis Actors Max, System Input -c parameter, class name, 2 files Pre-condition Files must contain Java source code Output XML report generated from System Post-condition Main scenario 1. Max uses System from cli with inputs 2. System runs classes diff, generates output and exit Alternative scenario 2a. System show an error message and exit 1/15/2014Software Engineering Course 8
  • 9. SOME USE CASES Name Full Diff Description System usage for full diff analysis Actors Max, System Input -f parameter, 2 files Pre-condition Files must contain Java source code Output XML report generated from System Post-condition Main scenario 1. Max uses System from cli with inputs 2. System runs full diff, generates output and exit Alternative scenario 2a. System show an error message and exit 1/15/2014Software Engineering Course 9
  • 10. USE CASES DIAGRAM 1/15/2014Software Engineering Course 10
  • 11. srcML: document-oriented XML representation of source code • Tool included in JavaDiff to convert java source file into XML documents • Combination of source code (text) and AST information (tags) • Simplified management of files content • Java structures easily identifiable SRCML TOOLKIT 1/15/2014Software Engineering Course Class Main { //… } <?xml version … </> Java Code srcML file 11
  • 12. JAVADIFF TOOL 1/15/2014Software Engineering Course Class Main { //… } Java Code Class Main { //… } Java Code <?xml version … </> XML report <?xml version … </> srcML file <?xml version … </> srcML file 12
  • 13. JAVADIFF EXAMPLE 1/15/2014Software Engineering Course 13 … public double sum (double a, double b) { double result=a+b; return result; } … … public int sum (double a, double b) { int result=a+b; return result; } … <Description> Differences between methods "sum" and "sum" in class "Calculator“ </Description> <DiffFactor> 30.0 </DiffFactor> <DiffResult> Same name - Type: double modified in int - statements DECL_STMT double result = a + b; modified in: DECL_STMT int result = a + b; </DiffResult> Java Code Java Code XML Report
  • 17. CLASS DIAGRAMS • JavaDiffApplication • CommandParser • ConsolePrinter • Src2SrcmlLauncher • OsSelector • JavaDiffCore • ReportPrinter • ObjectMarshaller • Description: • Represent javaDiff components 1/15/2014Software Engineering Course 17
  • 18. CLASS DIAGRAMS • SrcmlModel • SrcmlClass • SrcmlAttribute • SrcmlMethod • Parameter • Statement • Description: • Object representation for XML file generated with srcML tool 1/15/2014Software Engineering Course 18
  • 19. CLASS DIAGRAMS • DiffModel • DiffElement • DiffClassElement • DiffAttributeElement • DiffMethodElement • Description: • Contains elementary differences between srcML models • Added elements • Removed elements 1/15/2014Software Engineering Course 19
  • 20. CLASS DIAGRAMS • DiffReport • DiffReportElement • DiffElement • DiffClassElement • DiffAttributeElement • DiffMethodElement • Description: • Contains DiffElements with: • Elements info • Numeric difference factor • Details about differences between elements (class, attribute, method) 1/15/2014Software Engineering Course 20
  • 21. TECHNOLOGIES • Eclipse IDE (Juno SR1) for Java • Subversive (1.1.0): • Subversion (SVN) team provider • Eclipse plug-in • srcML (Trunk 13990 – 07 Jun 2012): • document-oriented XML representation of source code • Platform-dependent binaries integrated with Java’s ProcessBuilder • jDOM (2.0.4): • Java-based solution for accessing, manipulating, and outputting XML data from Java 1/15/2014Software Engineering Course 21
  • 22. SOFTWARE TESTING • Software Lifecycle Activity which is aimed for evaluating quality of a program and also for improving it • Process of verifying and validating that a software application or program • meets the business and technical requirements, that guided its design and development and works as expected • Identifies important errors • Other software quality factors: • Reliability • Performance • Security • Maintainability • … 1/15/2014Software Engineering Course 22
  • 23. • Functional Testing (Black-Box) • Checks conformance with specifications • Helps categorize inputs and derive expected outputs • Helps test case generation and test oracles • Our approach: Category-Partition Testing • The system is divided into individual “functions” that can be independently tested • The method identifies the parameters of each “function” and, for each parameter, identifies distinct categories • Allowable combinations of choices in the categories are converted in test data and test cases are generated TESTING APPROACH 1/15/2014Software Engineering Course 23
  • 24. • JavaDiff functions: Function Parameters 1 Attributes Diff –a “ClassName” “AttributeName” file1 file2 2 Methods Diff –m “ClassName” “MethodName” file1 file2 3 Classes Diff –c “ClassName” file1 file2 4 Quick Diff –q file1 file2 (also only file1 file2) 5 Detailed Diff -d file1 file2 6 Full Diff -f file1 file2 7 Show Help -h (also no parameters) 8 Show Version -v TESTING APPROACH 1/15/2014Software Engineering Course 24
  • 25. • Diff categories for (file1, file2) parameters in [1, 6] functions: 1. addedAttributes 2. addedClass 3. addedClassExtends 4. addedClassImports 5. addedClassInterfaces 6. addedClassSpecifiers 7. addedMethods 8. modifiedAttributes 9. modifiedClassExtends 10. modifiedClassImports 11. modifiedClassInterfaces 12. modifiedClassSpecifiers 13. modifiedMethods 14. modifiedPackage 15. removedAttributes 16. removedClass 17. removedClassExtends 18. removedClassImports 19. removedClassInterfaces 20. removedClassSpecifiers 21. removedMethods 22. removedPackage 23. renamedAttributes 24. renamedClass 25. renamedMethods TESTING APPROACH 1/15/2014Software Engineering Course 25
  • 26. • Other categories for (file1, file2) parameters in [4-6] functions: • GitHub1 • Github2 • Some other categories for parameters: • Input options error • Too many input options error • File path error (File not found) • System exceptions TESTING APPROACH 1/15/2014Software Engineering Course 26
  • 27. • Formal written test case: • Known input (Test Data) • Expected output, worked out before the test is executed • Automated test case generation with JUnit: • Open source framework used for writing & running tests • Test suites: 1. AttributesDiff Test Suite 2. Methods Diff Test Suite 3. Classes Diff Test Suite 4. Quick Diff Test Suite 5. Detailed Diff Test Suite 6. Full Diff Test Suite 7. Help Test Suite 8. Version Test Suite 9. Github Test Suite 10. Error Test Suite TEST CASES SPECIFICATION 1/15/2014Software Engineering Course 27
  • 28. • Attributes Diff function: Test Case testAttributesDiff() Test Description "Attributes Diff" funtion testing Class’ attribute comparison between (file1, file2) sources Actors Involved Classes JavaDiffApplication Preconditions Test Inputs (Data) String[] args = {"-a", "Calculator", "mem", file1, file2}; Expected Outputs Report identical to test oracle’s report Test Outputs Report Test Result Success Error Description Notes This Test Case was run for all 25 categories of (file1, file2) parameters TEST CASES 1/15/2014Software Engineering Course 28
  • 29. • Full Diff function: Test Case testFullDiff() Test Description "Full Diff" funtion testing Full comparison between (file1, file2) sources Actors Involved Classes JavaDiffApplication Preconditions Test Inputs (Data) String[] args = {"-f", file1, file2}; Expected Outputs Report identical to test oracle’s report Test Outputs Report Test Result Success Error Description Notes This Test Case was run for all 25 categories of (file1, file2) parameters TEST CASES 1/15/2014Software Engineering Course 29
  • 30. • Functional test coverage: • Test cases must cover system specifications • Code coverage: • measure used to describe the degree to which the source code is tested by test suites • EclEmma: • free Java code coverage tool for Eclipse • Coverage data can be exported in HTML, XML or CSV format • Testing results: • Covered Instructions: 98.4 % • Covered branches: 84.6% 1/15/2014Software Engineering Course 30 CODE COVERAGE