Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Program Slicing on Java byte-code for Locating Functional.

Slides:



Advertisements
Similar presentations
The Problem Decomposition of programs in terms of classes and in terms of crosscutting concerns are both useful, but languages based on source files allow.
Advertisements

Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extraction of.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Exploring the Neighborhood with Dora to Expedite Software Maintenance Emily Hill, Lori Pollock, K. Vijay-Shanker University of Delaware.
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
CS 536 Spring Intermediate Code. Local Optimizations. Lecture 22.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
Refactoring Support Tool: Cancer Yoshiki Higo Osaka University.
1 CMSC 132: Object-Oriented Programming II Java Constructs Department of Computer Science University of Maryland, College Park.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Introduction 01_intro.ppt
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University ICSE 2003 Java.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University STATIC ANALYSES FOR JAVA IN THE PRESENCE OF DISTRIBUTED COMPONENTS AND.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A lightweight.
2006/09/19AOAsia 21 Towards Locating a Functional Concern Based on a Program Slicing Technique Takashi Ishio 1,2, Ryusuke Niitani 2 and Katsuro Inoue 2.
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University DCCFinder: A Very- Large Scale Code Clone Analysis.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#
Chapter 6: User-Defined Functions
CMCD: Count Matrix based Code Clone Detection Yang Yuan and Yao Guo Key Laboratory of High-Confidence Software Technologies (Ministry of Education) Peking.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Design and Implementation.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
Homework #5 New York University Computer Science Department Data Structures Fall 2008 Eugene Weinstein.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University Dependence-Cache.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Retrieving Similar Code Fragments based on Identifier.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Towards Program.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University July 21, 2008WODA.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Cage: A Keyword.
Computer Science Projects Internal Assessment. Mastery Item Claimed Justification Where Listed Random Access File – Searching Lines P. 53 Random.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University A Slicing Method for Object-Oriented Programs Using Lightweight.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extraction of.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Extracting Sequence.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Power View Overview April 25, POWER VIEW Presentation ready visualizations for the masses.
Excel Translator™ Ultimate Risk Solutions, Inc.:
Spring 2016 Program Analysis and Verification
Chapter 7 User-Defined Methods.
User-Defined Functions
Introduction to javadoc
○Yuichi Semura1, Norihiro Yoshida2, Eunjong Choi3, Katsuro Inoue1
CSE401 Introduction to Compiler Construction
Parsing Costas Busch - LSU.
Introduction to javadoc
Presentation transcript:

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Program Slicing on Java byte-code for Locating Functional Concerns Takashi Ishio † Ryusuke Niitani † Gail Murphy ‡ Katsuro Inoue † † Osaka University, Japan ‡ University of British Columbia, Canada

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Concern Location A functional concern is code that helps fulfill a functional requirement.  A software maintenance task usually focuses on a functional concern. Concern location comprises “Search and Explore.”  Search “interesting” methods grep or other feature location tools  Explore the interaction among the methods call graph, class hierarchy tree, cross reference

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Example: Autosave function in jEdit jEdit periodically saves the contents of text area.  A user can specify the frequency. We can easily find Autosave class, Buffer.autosave() method and BufferIORequest.autosave() method. How the classes and methods are interacting?

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Exploring Interaction among methods Important information: control-flow and data-flow.  Which method triggers the autosave function.  Which class has a necessary data (e.g. filename).  How a method saves the contents to a text file. We have to read following classes: Autosave, Buffer, BufferIORequest, PerspeciveManager, VFSManager, FileVFS …

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Automated Concern Location We are trying to extract a concern graph from code fragments specified by a developer.  Our approach is based on program slicing.  Our tool is based on Soot, a Java bytecode analysis framework. Program Slicing with Heuristics Slice-to-ConcernGraph Translation Code fragments related to a functionality A concern graph a program slice

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Autosave concern graph Input = Autosave.*(), Buffer.autosave(), BufferIORequest.autosave()

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Program Slicing Slicing extracts statements related to criteria statements specified by a user. 1. A program P is converted to a program dependence graph. vertices: statements in P edges: control/data dependence relations 2. A user specifies “slicing criteria” statements in P. The statements are translated into “criteria vertices” in the PDG. 3. A program slice, a set of statements that affect or depend on criteria, is extracted by graph traversal from criteria vertices. 1i = 3; 2if (a > 0) { 3 print i; 4} data dependence control dependence use definition

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Slice including unrelated concerns Slicing usually extracts many statements.  A functional unit is connected to other units by control/data-flow.  28% on average in C program † † Binkley, D., Gold, N. and Harman, M.: An Empirical Study of Static Program Slice Size. ACM TOSEM Vol.16, No.2, Article 8, April AutosaveUndoManager autosave_dirty flag activateset/reset reset CompleteWord set slicing

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Slicing with Barriers A barrier is a vertex or an edge that terminate graph traversal †. † Krinke, J.: Slicing, Chopping, and Path Conditions with Barriers. Software Quality Journal, Vol.12, No.4, pp ,December AutosaveUndoManager autosave_dirty flag activateset/reset reset CompleteWord set A barrier blocks graph traversal. slicing

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Similarity-based Barrier The key idea is following: if two methods are contributing to the same functionality, the methods use similar methods, fields and classes. Name Set NS(m) = a set of types, classes, methods and fields referred in m. A long name is “tokenized”. e.g. “java.io.File”  “java”, “io”, “File”, “java.io.File”

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Example of Similarity package org.gjt.sp.util; class IntegerArray { private int[] array; private int len; public void add(int num){ if(len >= array.length) { int[] arrayN = new int[len * 2]; System.arraycopy(array,0,arrayN,0,len); array = arrayN; } array[len++] = num; } public final int getSize() { return len; } public final void setSize(int len) { this.len = len; } org.gjt.sp.util.IntegerArray, org, gjt, sp, util, integer, array, void, add, int, len, int[], java.lang.System, java, lang, system, arraycopy NS(IntegerArray.add) NS(IntegerArray.getSize) NS(IntegerArray.setSize) org.gjt.sp.util.IntegerArray, org, gjt, sp, util, integer, array, getSize, get, size, int, len org.gjt.sp.util.IntegerArray, org, gjt, sp, util, integer, array, len, setSize, set, size, void, int sim = sim = 0.639

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Identifying Barriers Program slicing is blocked at method m if m is not related to slicing criteria Similarity(m, C) ≦ threshold  A method m is related to slicing criteria if slicing criteria includes a method n such that m is similar to n. C = a set of methods that contain slicing criteria vertices.

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Slicing algorithm Slicing with summary edges and barriers  defined by Horwitz  extended by Krinke PDG based on Jimple code  “jimple” is an intermediate representation for bytecode. 3-address code Simple control-flow: “if” and “goto” Independent of JVM stack operation Calculate similarity for each method Code fragments related to a functionality a program slice Identify barriers Slicing with Barriers

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Visualizing a slice as a concern graph Concern Graph  A vertex is a class, a method or a field.  An edge represents a relation between two vertices. call, create, check, read, write, superclass, … We applied rule-based translation. † v1 in m1 v2 in m2 m1 m2 call call or parameter SliceConcern Graph † Kameda, D. and Takimoto, M.: Building Cocnern Graph Based on Program Slicing. IPSJ Transactions on Programming, Vol.46, No.11 (Pro 26), pp in Japanese. v1 in m1 READ obj.field m1 field read

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A graphical output with Graphviz We omit intra-class edges in graphical format.  Detail is provided in textual format. e.g. “Autosave.setInterval(interval) calls new Timer(interval, Autosave).”

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University The effectiveness of barriers Barriers reduced concern graph size:  1000 methods  20 methods  Printable on an A3 or A4-sized paper Comparing extracted graphs with hand-made concern graphs (not finished yet). Our previous experiment is reported in: 仁井谷竜介,石尾隆,井上克郎 : プログラムスライシングを用いた機能的 関心事の抽出手法の提案と実装. PPL in Japanese. concern graph size on 6 maintenance tasks on jEdit and our Slicer

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Information extracted from Java program To construct a dependence graph  Control dependence relation  Data dependence relation  Call Graph (with dynamic binding information) To identify barriers  a set of types, methods, fields referred in each method m To slice the dependence graph  Mapping source code to vertices

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Slicing Tool Overview Java Class Files PDG Slicer Slicing Criteria Concern Graph PDG Constructor Jimple 3-Address Code Call Graph Points-to Set Soot Framework ( ) SPARK Points-to Set Analysis Control-Flow Data-flow Analysis Annotated Jimple Translator

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Our effort to implement the system The program size  PDG Construction: 2731 LOC (without comments)  Slicing: 9296 LOC (without comments) slicing algorithms, heuristic functions and concern graph translation We could implement the PDG construction phase in two weeks:  One week to understand how Soot works.  The other week to implement code. Soot enabled us to focus on the essential part of the research idea.

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Advantage of Soot A rich analysis toolkit  Soot provides control-flow and data-flow for each method.  Jimple is simpler than source code and bytecode. Complex Java statements are simplified during compilation. Body Unit 1 n Stmt (Jimple code) is-a Value 1 n Expr is-a Control-flow Data-flow Local Exceptional UnitGraph SmartLocalDefs use Method

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Limitation of Soot  Soot is not a program analysis framework.  Soot keeps all data in memory to compile Jimple code to bytecode after the optimization.  Soot requires 2-4GB RAM to analyze jEdit and JDK.  Soot supports only the simple workflow: whole program analysis (call-graph construction) followed by local program analysis. We cannot implement a statistics tool (whole-program analysis) that uses the result of method-local analysis.

Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Summary Concern location based on program slicing  We introduced heuristics in order to extract a functional concern of interest to a developer. Input is the same as a traditional program slicing.  Most of graphs can be printed on an A3-sized paper. Soot framework reduced the implementation effort.  Soot is a good framework, but we hope a framework specialized for program analysis. easy-to-learn, extensible and scalable