Upload
joel-casey
View
212
Download
0
Embed Size (px)
Citation preview
CASE STUDIES OF ACCESSIBILITY EXCESSIVENESS ANALYSIS FOR JAVA PROGRAMS
Dotri Quoc
Inoue Laboratory
RESEARCH PROBLEM(1)ACCESS MODIFIER IN JAVA
public int[] A ; protected int c ; …..public void sort(){…}(default) int binarySearch(int value){…}private void process(){…}
CLASS1
Access Modifier
field declaration
method declaration
RESEARCH PROBLEM(2)
Access Modifier of fields/methods in Java : control the access of other classes to that field/method.
Access Modifier
Same Class
Package Subclass Any Class
Public OK OK OK OK
Protected OK OK OK -
Default OK OK - -
Private OK - - -
3
RESEARCH PROBLEM(3)
In Java, inexperienced/careless developers often set all of the access modifier public or default(no declaration)
The fields/methods which should be hidden are not hidden
Bugs in latter development/maintenance phase
4
EXAMPLE OF BAD ACCESS MODIFIER DECLARATION
Current program Main job
Other objects
Initialization
Public method A Public method B
Class X
Directly invoke B
Invoke
Future modification
OK
5
AE : ACCESSIBILITY EXCESSIVENESS(1/2)
AE : Discrepancy between declared access modifier and actual usage
An AE could cause unwilling access to method/field AE could be used as an indicator of immaturity of
developer
6
Access Modifier
Same Class
Package Subclass Any Class
Public OK OK OK OK
Protected OK OK OK -
Default OK OK - -
Private OK - - -
Declaration
Actual use
AE
AE : ACCESSIBILITY EXCESSIVENESS(2/2)
Acquirement of AE for each field/method AE causes bug in latter development and
maintenance phase
7
AE analysis tool : ModiChecker
APPROACH TO AE ANALYSIS(1)AE MAP
Actual Usage
Declaration Public Protected Default Private Unused
Public ok-pub0
pub1 pub2 pub3 pub4
Protected- ok-pro0 pro1 pro2 pro3
Default - - ok-def0 def1 def2
Private - - - ok-pri0 pri1
Syntax Error
No Discrepanc
y
AE IdAE Id of Excessive
fields/methods
Unused
8
APPROACH TO AE ANALYSIS(2) STATIC SOURCE CODE ANALYSIS
Requirement Information of each field/method’s access modifier
declaration Actual Usage of each field/method
MASU : Platform for Metrics measurement but is useful as a Java program analysis framework
9
Static source code Analysis is required
Employing MASU
MASU - http://sourceforge.net/projects/masu/
ARCHITECTURE OF MODICHECKER
10
Extraction of access modifier
declaration
Extraction of method/field
usage
ModiChecker
Source Code Analyzer
AST Database
MASU
Detection of declaration excessiveness
Input
Report of AE Id for each method/field
Source Code
Required Library(.jar
files)
OVERVIEW OF EXPERIMENT(1/2) Objectives of experiment
Validation of our approach Quantitative analysis of AE Id in some software systemsReasons for excessive/unused fields/methods
(found by interviewing developers)1. Reason 1 : Set for future use2. Reason 2 : Created by other program(automatic code
generators or refactoring tools…) or accessed by other programs(Java bean)
3. Reason 3 : Carelessness and immaturity Target Software
Industrial Software(341 Java files/ 64455 LOC)11
EXPERIMENT RESULT - FIELDS
Actual Usage
Declaration Public Protected Default Private Unused
Public 207 0 59 936 33
Protected- 0 9 18 0
Default - - 4 5 2
Private - - - 1123 5
12
EXPERIMENT RESULT - METHODS
Actual Usage
Declaration Public Protected Default Private Unused
Public 816 14 23 190 1005
Protected- 13 36 48 9
Default - - 0 3 0
Private - - - 488 4
13
EXPERIMENT RESULT
Excessive fields : 1027 Excessive methods : 512 Unused methods : 1018 Unused fields: 40
5 fields named serialVersionUIDIntentionally set for future use : 8Actually unused : 28 (5 fields contain
potential bug)
14
DISCUSSION
Validation of ModiChecker output Changed all of the excessive access modifier and
deleted some unused fields/methods Modified programs were compiled and executed
without any error Developer should look for the detailed result
and make decision to change/delete the unused/excessive fields/methods
15
CONCLUSION AND FUTURE WORK
ConclusionAnalysis method named AE for each
field/methodModiChecker : report AE of each
field/methodExperiment on some software systems
Future workModiChecker for other Java systems and
other programming language system(C# , C++…)
16
THANK YOU FOR YOUR ATTENTION
17