SlideShare a Scribd company logo
Defaultification Refactoring: A Tool for
Automatically Converting Java Methods to Default
Raffi Khatchadourian1
Hidehiko Masuhara2
1
CUNY Hunter College & the Graduate Center, 2
Tokyo Institute of Technology
Introduction
Java 8 enhanced interfaces enable developers to write default (instance)
methods that include an implementation that implementers will inherit
if one is not provided [13]. Advantages in migrating legacy code from
using the skeletal implementation pattern to default methods include
foregoing the need for subclassing, having classes inherit behavior (but
not state) from multiple interfaces [4], and facilitating local reason-
ing [9]. We demonstrate our tool Migrate Skeletal Implemen-
tation to Interface for transforming legacy Java code to use de-
fault methods.
The related Pull Up Method refactoring tool [3,14] manipulates
a type hierarchy by safely moving methods from a subclass up into a
super class so that all subclasses may inherit from it. This refactoring is
fundamentally different from migrating method definitions from skeletal
implementations to interfaces as default methods.
Our refactoring tool (available at http://git.io/v2nX0) is imple-
mented as an open source Eclipse (http://eclipse.org) plug-in built
atop of the Java Development Tools (JDT) (http://eclipse.org/jdt)
refactoring infrastructure [2]. For the tool evaluation, an extensive
refactoring test suite was created, featuring 259 refactoring regression
tests, triggered via continuous integration. The usefulness of the tool
was assess via the analysis of 19 Java projects of varying size and do-
main with a total of ∼2.7 million lines of code. Additionally, pull requests
(patches) of the refactoring results were submitted to popular GitHub
(http://github.com) repositories as a preliminary study.
The details of the underlying approach, as well as thorough experimen-
tal results, can be found in our previous work [8]. Beyond [8], we make
the following specific contributions:
Implementation details A thorough treatment of the novel aspects of
the tool implementation is presented in detail.
User perspective A broad overview of how our tool is used to perform
large-scale refactorings is given.
Envisioned Users
The users we envision our tool attracting are those who are tasked with
maintaining and/or improving legacy (currently) Java systems. Devel-
opers with even little refactoring experience may use our tool.
Software Engineering Challenges
Background and Motivation
Figure 1: Screenshot of the refactoring preview pane.
Fig. 1 portrays a screenshot of the refactoring preview pane that a user
is presented with prior to executing the refactoring on a simplified ex-
ample. Fig. 1 consists of two panes, namely, the “Original Source” and
the “Refactored Source,” with the former being in input to the tool and
the latter the proposed output.
Although useful, there are several drawbacks to the skeletal implemen-
tation pattern, especially w.r.t. inheritance, modularity, and bloat [8].
Many of the problems can be solved with default methods that are part
of the enhanced interface feature of Java 8 [5, Ch. 9]. With default
methods, implementers of I can simultaneously benefit from the default
implementation of m() and extend a different class.
Although Fig. 1 portrays a scenario where the refactoring succeeds,
cases exist where executing the refactoring would produce either type-
incorrect or semantically-inequivalent results. For example, consider the
following:
interface I {void m();}
interface J {default void m() {/* ... */}}
abstract class C implements I,J {void m() {/*...*/}}
Here, migrating method C.m() to interface I as a default method would
cause a compilation error due to class C now inheriting ambiguous
method definitions of method m(). Also, default methods have many
advantageous over the skeletal implementation pattern, however, there
are some potential trade-offs.
Implementation Challenges
Implementation-specific challenges include:
Architecture What is the best way to organize such a refactoring tool?
Reuse Given that the refactoring problem shares similarity with the
Pull Up Method refactoring, how can we best leverage
existing code from that plug-in here?
Applicability Do the various assumptions made in the approach scale
to real-world software refactoring?
Validation Given the significant number of “corner-cases” involved in
this refactoring, how can we ensure to developers that the
resulting refactoring code will be type-correct and
semantically equivalent to the original?
Usability Challenges
There are also challenges specific to developer adoption. Large scale
and broad changes may not be immediately appealing to developers of
mature and highly utilized projects due to risk.
Implementation
The Migrate Skeletal Implementation to Interface refac-
toring is implemented as an open source plug-in for the Eclipse IDE
(available at http://git.io/v2nX0).
Workflow
Figure 2: High-level system workflow.
Fig. 2 depicts the high-level workflow. The developer is presented with
options regarding the invasiveness of the refactoring (step 2). The bulk
of the computationally intensive precondition checking occurs in step
4.
Figure 3: Architecture and plug-in dependency diagram.
Architecture and Dependencies
Fig. 3 portrays the overall plug-in architecture and dependency overview
of our refactoring tool. The foundational Eclipse plug-ins and their de-
pendencies are also depicted in Fig. 3.
Relationship to Other Refactoring Plug-ins
The plug-in menu options are coupled with other Eclipse reorganization
refactorings. Some of our implementation leverages and adapts code
from the Eclipse Pull Up Method refactoring, especially those re-
lated to determining if a code entity is accessible from another type.
Technical Details
We make extensive use of ITypeHierarchy to traverse the input meth-
ods’ relationships to other types in the project. To demonstrate the
imperative-style code that realizes the more declarative-style type con-
straints, consider the constraint for method invocation. This constraint
applies to any program construct in the form of E.m(E1, . . . , En) to
a virtual method M where E is an expression. We must ensure that
there is a corresponding method in the type hierarchy of the destination
interface when E = this as the type of this will change.
We use ITypeHierarchy to check that the called method exists in
the destination interface’s “super type” hierarchy via a call to
IType.newSupertypeHierarchy(). The checking is achieved via the following:
mInHier = isInHier(calledMeth, destInterSuperHier);
boolean isMethInHier(IMethod m, ITypeHierarchy h) {
return Stream.of(h.getAllTypes()).anyMatch(t -> {
IMethod[] meths = t.findMethods(m);
return meth != null && meths.length > 0;});}
Real-world Applicability
To make our approach applicable to real-world scenarios, e.g., if an input
method’s destination interface is outside of the considered source code,
it is conservatively labeled as non-migratable (i.e., failed precondition).
Usability and Managing Risk
We allow developers to choose whether empty skeletal implementation
classes should be removed. We additionally require no mismatches in-
volving exception throws clauses and return types between source and
target methods. Lastly, an option to not consider non-standard (out-
side java.lang) annotation differences is available, which may be useful in
projects not using such processing frameworks. Developers have sev-
eral other options, including whether to include only abstract classes
as input, increasing the likelihood classes that truly are skeletal imple-
menters.
Evaluation
Our tool successfully converted ∼20% of methods possibly participating
in the skeletal implementation pattern to interfaces as default meth-
ods [8] in 19 real-world, open source projects of varying size and domain
with a total of ∼2.7 million lines of code. The correctness of the refac-
toring approach was validated by ensuring that no compilation errors
existed before and after the refactoring. Furthermore, we verified that
all unit tests results were identical before and after the refactoring. A
preliminary pull request study was also performed to ensure that the
musically produced results matched what experienced developers may
have written. Four projects accepted our pull requests, and the tool’s
results were integrated into the projects.
To validate our implementation, our plug-in features an extensive refac-
toring test suite with over 200 tests. The significant number of test
cases exercises many corner-cases that appear in the refactoring.
Related Work
Current Eclipse refactorings do not have the capability to deal with de-
fault method conversions. An important difference between our tool
and Pull Up Method is related to a “stubbing” behavior. For ex-
ample, in Pull Up Method, if an instance method call in the source
method exists, that method may be available in the target type. If it
is not, an abstract method (stub) can be created in the target type
to compensate. However, in our case, there may be no relationship
between the called instance method and the destination interface.
Others [1,12,14] reorganize type hierarchies, but not for default meth-
ods. [6,7] transform Java programs to use lambda expressions and enu-
merated types, respectively, while [11] demacrofies C++11 programs.
Conclusion & Future Work
A refactoring tool that incorporates an efficient, fully-automated,
type constraint-based, semantics-preserving approach that migrates the
skeletal implementation pattern in legacy Java code to instead use de-
fault methods has been demonstrated. The tool is implemented as an
Eclipse IDE plug-in and was evaluated using several techniques.
In the future, we plan to compensate for situations where source meth-
ods directly accessing fields or methods outside destination interfaces.
We also plan to improve refactoring speed [10].
References
[1] Zakarea Alshara, Abdelhak-Djamel Seriai, Chouki Tibermacine, Hinde Lilia Bouziane,
Christophe Dony, and Anas Shatnawi. Migrating large object-oriented applications into
component-based ones: Instantiation and inheritance transformation. In International Con-
ference on Generative Programming: Concepts & Experience, 2015.
[2] Dirk Bäumer, Erich Gamma, and Adam Kiezun. Integrating refactoring support into a Java
development tool. In ACM SIGPLAN conference on Object-Oriented Programming, Systems,
Languages, and Applications, 2001.
[3] Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley Profes-
sional, 1999.
[4] Brian Goetz. Interface evolution via virtual extensions methods. Technical report, Oracle
Corporation, June 2011.
[5] James Gosling, Bill Joy, Guy L. Steele, Gilad Bracha, and Alex Buckley. The Java Language
Specification. Addison-Wesley Professional, 2014.
[6] Alex Gyori, Lyle Franklin, Danny Dig, and Jan Lahoda. Crossing the gap from imperative to
functional programming through refactoring. In ACM SIGSOFT International Symposium on
the Foundations of Software Engineering, 2013.
[7] Raffi Khatchadourian. Automated refactoring of legacy Java software to enumerated types.
Automated Software Engineering, 24(4):757–787, December 2017.
[8] Raffi Khatchadourian and Hidehiko Masuhara. Automated refactoring of legacy Java software
to default methods. In International Conference on Software Engineering, 2017.
[9] Raffi Khatchadourian, Olivia Moore, and Hidehiko Masuhara. Towards improving interface
modularity in legacy java software through automated refactoring. In International Conference
on Modularity Companion, 2016.
[10] Jongwook Kim, Don Batory, Danny Dig, and Maider Azanza. Improving refactoring speed by
10x. In International Conference on Software Engineering, 2016.
[11] Aditya Kumar, Andrew Sutton, and Bjarne Stroustrup. Rejuvenating C++ programs through
demacrofication. In International Conference on Software Maintenance, 2012.
[12] Ivan Moore. Automatic inheritance hierarchy restructuring and method refactoring. In ACM
SIGPLAN conference on Object-Oriented Programming, Systems, Languages, and Applications,
1996.
[13] Oracle Corporation. Java Programming Language Enhancements.
[14] Frank Tip, Robert M. Fuhrer, Adam Kieżun, Michael D. Ernst, Ittai Balaban, and Bjorn De Sut-
ter. Refactoring using type constraints. ACM Transactions on Programming Languages and
Systems, 2011.
International Conference on Automated Software Engineering, Oct 30–Nov 3, 2017, Urbana-Champaign, Illinois, USA

More Related Content

PDF
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
PDF
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
PDF
Poster on Automated Refactoring of Legacy Java Software to Default Methods
PDF
Automated Refactoring of Legacy Java Software to Default Methods Talk at ICSE...
PDF
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
PDF
Automatic Migration of Legacy Java Method Implementations to Interfaces
PPTX
Type Annotations in Java 8
PDF
Database access and JDBC
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Automated Refactoring of Legacy Java Software to Default Methods Talk at ICSE...
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
Automatic Migration of Legacy Java Method Implementations to Interfaces
Type Annotations in Java 8
Database access and JDBC

What's hot (20)

PDF
Technical interview questions
PDF
Applicative Logic Meta-Programming as the foundation for Template-based Progr...
PPTX
Java Annotations
PDF
Exception handling
PDF
Swing api
PDF
Java Interview Questions
PDF
Object Oriented Programming Lab Manual
PDF
CS5393-Korat_Mittal_Akshay_ProjReport
PDF
Java Annotation Processing: A Beginner Walkthrough
PDF
Distributed Programming (RMI)
PPT
Introduction to java programming part 2
PPT
Java Basics
DOCX
The Seven Pillars Of Asp.Net
PDF
Java lab1 manual
PPT
Java interfaces
PPT
Spring AOP
PPT
Java Tutorial
PPTX
Interface java
PDF
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
PPT
Java interview-questions-and-answers
Technical interview questions
Applicative Logic Meta-Programming as the foundation for Template-based Progr...
Java Annotations
Exception handling
Swing api
Java Interview Questions
Object Oriented Programming Lab Manual
CS5393-Korat_Mittal_Akshay_ProjReport
Java Annotation Processing: A Beginner Walkthrough
Distributed Programming (RMI)
Introduction to java programming part 2
Java Basics
The Seven Pillars Of Asp.Net
Java lab1 manual
Java interfaces
Spring AOP
Java Tutorial
Interface java
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
Java interview-questions-and-answers
Ad

Similar to Defaultification Refactoring: A Tool for Automatically Converting Java Methods to Default (20)

PPTX
Why We Refactor? Confessions of GitHub Contributors
PDF
Refactoring
PDF
A Model To Compare The Degree Of Refactoring Opportunities Of Three Projects ...
PDF
A MODEL TO COMPARE THE DEGREE OF REFACTORING OPPORTUNITIES OF THREE PROJECTS ...
PDF
Icsme 2021-keynote-creating-usable-and-useful-software-tools
PDF
Proactive Empirical Assessment of New Language Feature Adoption via Automated...
PDF
Apsec 2014 Presentation
PDF
Introduction to refactoring
PPTX
Recommending Refactorings based on Team Co-Maintenance Patterns
PDF
Refactoring 2TheMax (con ReSharper)
PDF
ARIES: An Eclipse Plug-in To Support Extract Class Refactoring
PDF
A Multi-Objective Refactoring Approach to Introduce Design Patterns and Fix A...
PDF
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
PPTX
Week 2 SREE.pptx Software reengieering ucp sllides
PPTX
Refactoring in Software Reengineering .pptx
PDF
Recommending refactoring operations in large software systems
PDF
Refactoring: Improve the design of existing code
PPTX
SAD10 - Refactoring
PPTX
Everything you Wanted to Know About Refactoring
PDF
Architecture refactoring - accelerating business success
Why We Refactor? Confessions of GitHub Contributors
Refactoring
A Model To Compare The Degree Of Refactoring Opportunities Of Three Projects ...
A MODEL TO COMPARE THE DEGREE OF REFACTORING OPPORTUNITIES OF THREE PROJECTS ...
Icsme 2021-keynote-creating-usable-and-useful-software-tools
Proactive Empirical Assessment of New Language Feature Adoption via Automated...
Apsec 2014 Presentation
Introduction to refactoring
Recommending Refactorings based on Team Co-Maintenance Patterns
Refactoring 2TheMax (con ReSharper)
ARIES: An Eclipse Plug-in To Support Extract Class Refactoring
A Multi-Objective Refactoring Approach to Introduce Design Patterns and Fix A...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Week 2 SREE.pptx Software reengieering ucp sllides
Refactoring in Software Reengineering .pptx
Recommending refactoring operations in large software systems
Refactoring: Improve the design of existing code
SAD10 - Refactoring
Everything you Wanted to Know About Refactoring
Architecture refactoring - accelerating business success
Ad

More from Raffi Khatchadourian (20)

PDF
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
PDF
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
PDF
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
PDF
Towards Safe Automated Refactoring of Imperative Deep Learning Programs to Gr...
PDF
Automated Evolution of Feature Logging Statement Levels Using Git Histories a...
PDF
A Tool for Rejuvenating Feature Logging Levels via Git Histories and Degree o...
PDF
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
PPTX
Actor Concurrency Bugs: A Comprehensive Study on Symptoms, Root Causes, API U...
PDF
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
PDF
Automated Evolution of Feature Logging Statement Levels Using Git Histories a...
PDF
An Empirical Study on the Use and Misuse of Java 8 Streams
PDF
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams
PDF
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams
PDF
A Brief Introduction to Type Constraints
PDF
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
PDF
A Tool for Optimizing Java 8 Stream Software via Automated Refactoring
PDF
Porting the NetBeans Java 8 Enhanced For Loop Lambda Expression Refactoring t...
PDF
Towards Safe Refactoring for Intelligent Parallelization of Java 8 Streams
PDF
Detecting Broken Pointcuts using Structural Commonality and Degree of Interest
PDF
Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Sof...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Towards Safe Automated Refactoring of Imperative Deep Learning Programs to Gr...
Automated Evolution of Feature Logging Statement Levels Using Git Histories a...
A Tool for Rejuvenating Feature Logging Levels via Git Histories and Degree o...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Actor Concurrency Bugs: A Comprehensive Study on Symptoms, Root Causes, API U...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
Automated Evolution of Feature Logging Statement Levels Using Git Histories a...
An Empirical Study on the Use and Misuse of Java 8 Streams
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams
A Brief Introduction to Type Constraints
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
A Tool for Optimizing Java 8 Stream Software via Automated Refactoring
Porting the NetBeans Java 8 Enhanced For Loop Lambda Expression Refactoring t...
Towards Safe Refactoring for Intelligent Parallelization of Java 8 Streams
Detecting Broken Pointcuts using Structural Commonality and Degree of Interest
Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Sof...

Recently uploaded (20)

PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Nekopoi APK 2025 free lastest update
PPTX
Transform Your Business with a Software ERP System
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Digital Strategies for Manufacturing Companies
PDF
System and Network Administration Chapter 2
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Navsoft: AI-Powered Business Solutions & Custom Software Development
Softaken Excel to vCard Converter Software.pdf
top salesforce developer skills in 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Reimagine Home Health with the Power of Agentic AI​
How Creative Agencies Leverage Project Management Software.pdf
Nekopoi APK 2025 free lastest update
Transform Your Business with a Software ERP System
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
CHAPTER 2 - PM Management and IT Context
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Upgrade and Innovation Strategies for SAP ERP Customers
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Digital Strategies for Manufacturing Companies
System and Network Administration Chapter 2
wealthsignaloriginal-com-DS-text-... (1).pdf
Understanding Forklifts - TECH EHS Solution
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...

Defaultification Refactoring: A Tool for Automatically Converting Java Methods to Default

  • 1. Defaultification Refactoring: A Tool for Automatically Converting Java Methods to Default Raffi Khatchadourian1 Hidehiko Masuhara2 1 CUNY Hunter College & the Graduate Center, 2 Tokyo Institute of Technology Introduction Java 8 enhanced interfaces enable developers to write default (instance) methods that include an implementation that implementers will inherit if one is not provided [13]. Advantages in migrating legacy code from using the skeletal implementation pattern to default methods include foregoing the need for subclassing, having classes inherit behavior (but not state) from multiple interfaces [4], and facilitating local reason- ing [9]. We demonstrate our tool Migrate Skeletal Implemen- tation to Interface for transforming legacy Java code to use de- fault methods. The related Pull Up Method refactoring tool [3,14] manipulates a type hierarchy by safely moving methods from a subclass up into a super class so that all subclasses may inherit from it. This refactoring is fundamentally different from migrating method definitions from skeletal implementations to interfaces as default methods. Our refactoring tool (available at http://git.io/v2nX0) is imple- mented as an open source Eclipse (http://eclipse.org) plug-in built atop of the Java Development Tools (JDT) (http://eclipse.org/jdt) refactoring infrastructure [2]. For the tool evaluation, an extensive refactoring test suite was created, featuring 259 refactoring regression tests, triggered via continuous integration. The usefulness of the tool was assess via the analysis of 19 Java projects of varying size and do- main with a total of ∼2.7 million lines of code. Additionally, pull requests (patches) of the refactoring results were submitted to popular GitHub (http://github.com) repositories as a preliminary study. The details of the underlying approach, as well as thorough experimen- tal results, can be found in our previous work [8]. Beyond [8], we make the following specific contributions: Implementation details A thorough treatment of the novel aspects of the tool implementation is presented in detail. User perspective A broad overview of how our tool is used to perform large-scale refactorings is given. Envisioned Users The users we envision our tool attracting are those who are tasked with maintaining and/or improving legacy (currently) Java systems. Devel- opers with even little refactoring experience may use our tool. Software Engineering Challenges Background and Motivation Figure 1: Screenshot of the refactoring preview pane. Fig. 1 portrays a screenshot of the refactoring preview pane that a user is presented with prior to executing the refactoring on a simplified ex- ample. Fig. 1 consists of two panes, namely, the “Original Source” and the “Refactored Source,” with the former being in input to the tool and the latter the proposed output. Although useful, there are several drawbacks to the skeletal implemen- tation pattern, especially w.r.t. inheritance, modularity, and bloat [8]. Many of the problems can be solved with default methods that are part of the enhanced interface feature of Java 8 [5, Ch. 9]. With default methods, implementers of I can simultaneously benefit from the default implementation of m() and extend a different class. Although Fig. 1 portrays a scenario where the refactoring succeeds, cases exist where executing the refactoring would produce either type- incorrect or semantically-inequivalent results. For example, consider the following: interface I {void m();} interface J {default void m() {/* ... */}} abstract class C implements I,J {void m() {/*...*/}} Here, migrating method C.m() to interface I as a default method would cause a compilation error due to class C now inheriting ambiguous method definitions of method m(). Also, default methods have many advantageous over the skeletal implementation pattern, however, there are some potential trade-offs. Implementation Challenges Implementation-specific challenges include: Architecture What is the best way to organize such a refactoring tool? Reuse Given that the refactoring problem shares similarity with the Pull Up Method refactoring, how can we best leverage existing code from that plug-in here? Applicability Do the various assumptions made in the approach scale to real-world software refactoring? Validation Given the significant number of “corner-cases” involved in this refactoring, how can we ensure to developers that the resulting refactoring code will be type-correct and semantically equivalent to the original? Usability Challenges There are also challenges specific to developer adoption. Large scale and broad changes may not be immediately appealing to developers of mature and highly utilized projects due to risk. Implementation The Migrate Skeletal Implementation to Interface refac- toring is implemented as an open source plug-in for the Eclipse IDE (available at http://git.io/v2nX0). Workflow Figure 2: High-level system workflow. Fig. 2 depicts the high-level workflow. The developer is presented with options regarding the invasiveness of the refactoring (step 2). The bulk of the computationally intensive precondition checking occurs in step 4. Figure 3: Architecture and plug-in dependency diagram. Architecture and Dependencies Fig. 3 portrays the overall plug-in architecture and dependency overview of our refactoring tool. The foundational Eclipse plug-ins and their de- pendencies are also depicted in Fig. 3. Relationship to Other Refactoring Plug-ins The plug-in menu options are coupled with other Eclipse reorganization refactorings. Some of our implementation leverages and adapts code from the Eclipse Pull Up Method refactoring, especially those re- lated to determining if a code entity is accessible from another type. Technical Details We make extensive use of ITypeHierarchy to traverse the input meth- ods’ relationships to other types in the project. To demonstrate the imperative-style code that realizes the more declarative-style type con- straints, consider the constraint for method invocation. This constraint applies to any program construct in the form of E.m(E1, . . . , En) to a virtual method M where E is an expression. We must ensure that there is a corresponding method in the type hierarchy of the destination interface when E = this as the type of this will change. We use ITypeHierarchy to check that the called method exists in the destination interface’s “super type” hierarchy via a call to IType.newSupertypeHierarchy(). The checking is achieved via the following: mInHier = isInHier(calledMeth, destInterSuperHier); boolean isMethInHier(IMethod m, ITypeHierarchy h) { return Stream.of(h.getAllTypes()).anyMatch(t -> { IMethod[] meths = t.findMethods(m); return meth != null && meths.length > 0;});} Real-world Applicability To make our approach applicable to real-world scenarios, e.g., if an input method’s destination interface is outside of the considered source code, it is conservatively labeled as non-migratable (i.e., failed precondition). Usability and Managing Risk We allow developers to choose whether empty skeletal implementation classes should be removed. We additionally require no mismatches in- volving exception throws clauses and return types between source and target methods. Lastly, an option to not consider non-standard (out- side java.lang) annotation differences is available, which may be useful in projects not using such processing frameworks. Developers have sev- eral other options, including whether to include only abstract classes as input, increasing the likelihood classes that truly are skeletal imple- menters. Evaluation Our tool successfully converted ∼20% of methods possibly participating in the skeletal implementation pattern to interfaces as default meth- ods [8] in 19 real-world, open source projects of varying size and domain with a total of ∼2.7 million lines of code. The correctness of the refac- toring approach was validated by ensuring that no compilation errors existed before and after the refactoring. Furthermore, we verified that all unit tests results were identical before and after the refactoring. A preliminary pull request study was also performed to ensure that the musically produced results matched what experienced developers may have written. Four projects accepted our pull requests, and the tool’s results were integrated into the projects. To validate our implementation, our plug-in features an extensive refac- toring test suite with over 200 tests. The significant number of test cases exercises many corner-cases that appear in the refactoring. Related Work Current Eclipse refactorings do not have the capability to deal with de- fault method conversions. An important difference between our tool and Pull Up Method is related to a “stubbing” behavior. For ex- ample, in Pull Up Method, if an instance method call in the source method exists, that method may be available in the target type. If it is not, an abstract method (stub) can be created in the target type to compensate. However, in our case, there may be no relationship between the called instance method and the destination interface. Others [1,12,14] reorganize type hierarchies, but not for default meth- ods. [6,7] transform Java programs to use lambda expressions and enu- merated types, respectively, while [11] demacrofies C++11 programs. Conclusion & Future Work A refactoring tool that incorporates an efficient, fully-automated, type constraint-based, semantics-preserving approach that migrates the skeletal implementation pattern in legacy Java code to instead use de- fault methods has been demonstrated. The tool is implemented as an Eclipse IDE plug-in and was evaluated using several techniques. In the future, we plan to compensate for situations where source meth- ods directly accessing fields or methods outside destination interfaces. We also plan to improve refactoring speed [10]. References [1] Zakarea Alshara, Abdelhak-Djamel Seriai, Chouki Tibermacine, Hinde Lilia Bouziane, Christophe Dony, and Anas Shatnawi. Migrating large object-oriented applications into component-based ones: Instantiation and inheritance transformation. In International Con- ference on Generative Programming: Concepts & Experience, 2015. [2] Dirk Bäumer, Erich Gamma, and Adam Kiezun. Integrating refactoring support into a Java development tool. In ACM SIGPLAN conference on Object-Oriented Programming, Systems, Languages, and Applications, 2001. [3] Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley Profes- sional, 1999. [4] Brian Goetz. Interface evolution via virtual extensions methods. Technical report, Oracle Corporation, June 2011. [5] James Gosling, Bill Joy, Guy L. Steele, Gilad Bracha, and Alex Buckley. The Java Language Specification. Addison-Wesley Professional, 2014. [6] Alex Gyori, Lyle Franklin, Danny Dig, and Jan Lahoda. Crossing the gap from imperative to functional programming through refactoring. In ACM SIGSOFT International Symposium on the Foundations of Software Engineering, 2013. [7] Raffi Khatchadourian. Automated refactoring of legacy Java software to enumerated types. Automated Software Engineering, 24(4):757–787, December 2017. [8] Raffi Khatchadourian and Hidehiko Masuhara. Automated refactoring of legacy Java software to default methods. In International Conference on Software Engineering, 2017. [9] Raffi Khatchadourian, Olivia Moore, and Hidehiko Masuhara. Towards improving interface modularity in legacy java software through automated refactoring. In International Conference on Modularity Companion, 2016. [10] Jongwook Kim, Don Batory, Danny Dig, and Maider Azanza. Improving refactoring speed by 10x. In International Conference on Software Engineering, 2016. [11] Aditya Kumar, Andrew Sutton, and Bjarne Stroustrup. Rejuvenating C++ programs through demacrofication. In International Conference on Software Maintenance, 2012. [12] Ivan Moore. Automatic inheritance hierarchy restructuring and method refactoring. In ACM SIGPLAN conference on Object-Oriented Programming, Systems, Languages, and Applications, 1996. [13] Oracle Corporation. Java Programming Language Enhancements. [14] Frank Tip, Robert M. Fuhrer, Adam Kieżun, Michael D. Ernst, Ittai Balaban, and Bjorn De Sut- ter. Refactoring using type constraints. ACM Transactions on Programming Languages and Systems, 2011. International Conference on Automated Software Engineering, Oct 30–Nov 3, 2017, Urbana-Champaign, Illinois, USA