0% found this document useful (0 votes)
90 views

Analyzing Relationships Classes

1) The document discusses analyzing relationships between classes in Java program code using a tool called Rfind. Rfind searches code line-by-line to find keywords indicating relationships and represents the code as a graph. 2) The tool was updated to recognize inheritance by searching for "extends" and "implements" keywords and representing inheritance relationships as graph edges. This allows tracking of subclass to superclass connections. 3) The updated tool provides more detailed analysis outputs, including a new file listing inheritance relationships and ability to determine differences between desktop, mobile, and web applications.

Uploaded by

Andrej Arbanas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Analyzing Relationships Classes

1) The document discusses analyzing relationships between classes in Java program code using a tool called Rfind. Rfind searches code line-by-line to find keywords indicating relationships and represents the code as a graph. 2) The tool was updated to recognize inheritance by searching for "extends" and "implements" keywords and representing inheritance relationships as graph edges. This allows tracking of subclass to superclass connections. 3) The updated tool provides more detailed analysis outputs, including a new file listing inheritance relationships and ability to determine differences between desktop, mobile, and web applications.

Uploaded by

Andrej Arbanas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1

Analyzing relationships between classes in Java


programme code
ANDREJ ARBANAS and JOSIP PERIC, University of Rijeka, Faculty of Engineering

Many complex systems use the graph structure to more easily explain connections between certain elements. Program code is
an abstract structure that can be displayed in many ways, among which is the graph view containing edges and vertices. When
mentioning program code in this project, it is reffered to Java programming language and object oriented programming. It is
based on defining classes which are written in different locations in memory, and they communicate via methods, exchange
data, perform tasks and so on. In order to store the program code, that is his relations, as a graph, Rfind tool is used. Rfind
looks for relations between Java classes using keywords. It is written in C++ and works with Linux operating systems. It shows
lists of all classes and their relations inside the programme code. In this paper we analyze open source Java programmes to
determine the difference of inheriting classes between desktop, mobile and web applications.
Categories and Subject Descriptors: H.5.2 [Information Interfaces and Presentation]: User InterfacesEvaluation/
methodology
General Terms: Analysis
Additional Key Words and Phrases: open-source repositories, automatic tool, software analysis

1. INTRODUCTION
Graph is a mathematical structure amounting to a set of objects in which some pairs of the objects
are in some sense related. The objects correspond to mathematical abstractions called vertices (also
called nodes or points) and each of the related pairs of vertices is called an edge (also called an arc or
line). When it is talked about graphs in program code they can be related to network graphs which
are studied in lots of papers [R. Milo, S. Shen-Orr, S. Itzkovitz, et al. Network motifs: simple building
blocks of complex networks, Science 2002; 298:82427, 2002.]. Besides graphs it is also important to
mention the subgraphs from which the topological network structure is build. There are different kinds
of subgraphs, but for networking and programme code the most important one is 3-node subgraph.
Figure 1 shows all types of 3-node subgraphs with their orientation. It is important to mention that in
programme code there is a big difference if class X calls class Y or class Y calls class X.

Fig. 1. All types of 3-node subgraphs shown with all possible orientations

ACM Transactions on Applied Perception, Vol. 2, No. 3, Article 1, Publication date: May 2010.
1:2 A. Arbanas, J. Peric

This projects main task was adding a functionality to recognize inheritance inside Java
code, therefore this chapter will contain details regarding inheritance and its usage. The definition of
inheritance is referring to process in which one class inherits a part or the whole structure and func-
tionalities of another class. If the class B is a subclass of class A, then the class A is the superclass of
B. Subclass to superclass relation is often pictured as a diagram in which the subclass is under the su-
perclass and pointing towards it (Figure 2). In program code, inheritance is conducted using keywords.

Fig. 2. Inheritance of two classes

It is worth emphasizing that subclasses inherit all variables or methods of its superclass if they are
declared public or protected, and of course dont, if they are private. Also, variables and methods with
the same name as in its subclass are not inherited. Polymorphism is term thats strongly relevant to
inheritance and this project. It is part of inheritance where class processing is changing functionality
or arguments in methods of superclasses. There is also one important part of polymorphism, when
working with Java code and inheriting interface. In these situations class processing is happening all
the time, because it is the only way of using some parts of user interface.

2. TOOL
Rfind [J. Petric and T. Galinac Grbac. Software structure evolution and relation to system defective-
ness. In Proceedings of the 18th International Conference on Evaluation and Assessment in Software
Engineering EASE2014, London, UK, 2014.] is a tool that looks for relations between Java classes us-
ing keywords such as new, import etc., and its written in C++ programming language. Rfind searches
the code line by line and finds matching keywords in order to change object oriented programming into
a graph, for easier understanding of classes and their connections. Java class represents a graph node
and the communication links are the edges. By communication links, its alluded on all possible inter-
class connections such as sending parameters, using inherited methods and returning certain values
etc. The first version of tool was generating two files after execution, .graph and .classlist. The .classlist
file contains class names and their generated IDs (e.g. 1 ->nameOfClass), and .graph file contains
information on relations between classes as ordered pairs (e.g. 1 ->2).
The first version of this tool was going through lines of Java code searching for keywords
package, import, class, new, and finding all types of methods. When it finds the word package text next
to it is a name of folder in which class is stored, and it is used to write the name of the package in
.classlist file (e.g. 1 ->package.className). Next to the keyword class is the name of the current class,
and it can be stored in the className. All the imported packages are analyzed when tool finds the
name of a package next to the keyword import and are stored in memory so they can be used later.
The connections between classes are made when methods are called and compared with all imported
packages. If an argument from method has the same name as one of the imported packages in this class
than the tool makes a link between two classes. Sometimes the same method with same arguments is
ACM Transactions on Applied Perception, Vol. 2, No. 3, Article 1, Publication date: May 2010.
Analyzing relationships between classes in Java programme code 1:3

called more than once, because of that when tool finds the last line of current class it calls a method
that removes all duplicated links. While Rfind is running it writes names of all classes in terminal
that are found in code, so in the end whole class list is displayed. Figure 3 shows output of first Rfind

Fig. 3. Data recived from first version of Rfind

version. Top left part is .classlist file with all classNames and their unique IDs, underneath is figure of
Terminal with class names found in code. On the top right side is file in which is written count of links
from each class and total number of links for one project, and last figure is .graphlist file which shows
IDs of linked classes. Red circled class is just an example to show connection for all described files.
In the 2nd version of Rfind we implemented some new features for better Java code analysis
and to collect more data. Main task was to implement searching and making links of inheritance be-
tween classes, counting inheritance and making new file (.inheritance) in which will be written links
between classes that have some type of inheritance. Firstly we implemented searching for new key-
words extends and implements in lines of code. The task was to make a link between classes if keyword
is found, we didnt have to follow inheritance deep inside the class structure. When inheritance be-
tween classes is found it is written as a standard link in .graphlist file, and also to new .inheritance
file. By adding this feature we can now track more connections between classes and see exactly which
class is inheriting another class. After Rfind finishes analyzing code, except from class names in Termi-
nal, the tool is now also writing how many links of inheritance there is, as well as from which are with
keyword extends and which are from word implements. File .inheritance writes data in three columns,
first one is subclass, the next column is superclass and the last one is type of inheritance (meaning by
keyword extends or implements). To define superclass it is used a name of class which stands by one
of the keywords for inheriting with its package that must be imported inside the subclass. Figure 4
shows output of same project as described in figure 3 but analyzing with updated version of Rfind. In
the top left corner is preview of .inheritance file written in columns as mentioned before, underneath
is .classlist file, and at the bottom is picture of Terminal with number of classes (total and divided
by extends or implements). On the right side is count of links between classes and .graphlist file. In
ACM Transactions on Applied Perception, Vol. 2, No. 3, Article 1, Publication date: May 2010.
1:4 A. Arbanas, J. Peric

Fig. 4. Data received from second version of Rfind

this example red circled class is the same one as in Figure 3, also included in file .inheritance. On
this project first version of Rfind found 16.924 links between classes, but updated version found 19.750
links (from which are inherited 3.153, with keyword extends 2.264, and with keyword implements 889).
Based on this data we can conclude that there is lot of inheriting inside the Java programming, and
with this update tool can now be used for more accurate code analysis. Using Rfinds improved version
were getting a much more detailed analysis of Java program code as it can be seen on figures 3 and
4. Besides relations number increase, with the improved version we can also trace exactly which class
is a superclass of a certain subclass and the correct number of extended and implemented inherited
relations. Using that data one can notice if there is a statistically relevant difference between Java
applications made for desktop, web and mobile usage.

3. RESULTS
Upon finishing programming and implementing Rfinds new functionalities, an analysis between old
and new tool versions was made. The idea was to compare the premodified programs output with
newly generated data from big Java projects containing all sorts of relations including inherited ones.
First of all, JDT and PDE projects were analyzed and compared, giving the output as in several tables
below. Tables contain columns Relations before, which shows how many relation was found before
altering any of the initial Rfinds programme code. Relations after is the number of relations after all
the changes, while Inherited relations counts only the relations that are made via inheritance process,
meaning by keywords sorted in next two columns as following, Extended and Implemented.
ACM Transactions on Applied Perception, Vol. 2, No. 3, Article 1, Publication date: May 2010.
Analyzing relationships between classes in Java programme code 1:5

Relations before Relations after Inherited relations Extended Implemented


JDT
R2 0 1524 2020 507 368 139
R2 1 2161 2798 657 474 183
R3 0 2362 3159 824 583 241
R3 1 3786 4828 1078 770 308
R3 2 6674 7975 1348 975 373
R3 3 8310 9924 1674 1208 466
R3 4 8528 10798 2351 1592 759
R3 5 9195 11598 2487 1712 775
R3 6 9594 12099 2592 1781 811
R3 7 9720 12238 2607 1796 811
R3 8 9853 12414 2653 1834 819
R4 2 9853 12414 2653 1834 819
R4 3 9836 12416 2668 1840 828

Table 1 : JDT results table


Table above represents a comparison of all the JDT projects and clearly shows its newly
generated relations, how many of them were inherited and in which way. Same was done for the
similar, PDE projects. It is easily noticeable that its a complex project containing additional relations
compared to pre-modified tool.

Relations before Relations after Inherited relations Extended Implemented


PDE
R1 0 2148 2710 580 349 231
R2 0 5094 6007 959 639 320
R2 1 7123 8316 1263 871 392
R2 1 1 7124 8317 1263 871 392
R2 1 2 7104 8295 1261 870 391
R3 0 9924 11638 1880 1257 623
R3 1 11603 13653 2272 1546 726
R3 2 13787 16294 2794 1936 858
R3 3 14674 17325 2946 2066 880
R3 4 15787 18485 3008 2136 872
R3 5 16385 19158 3093 2213 880
R3 6 16564 19359 3120 2234 886
R3 7 16635 19445 3131 2243 888
R3 8 16878 19700 3147 2257 890
R4 2 16878 19700 3147 2257 890
R4 3 16924 19750 3153 2264 889

Table 2 : PDE results table


ACM Transactions on Applied Perception, Vol. 2, No. 3, Article 1, Publication date: May 2010.
1:6 A. Arbanas, J. Peric

After iterating through the initial two project groups, JDT and PDE, an additional analysis was made.
The idea was to test the programs behavior on large, open source projects from different areas and as-
pects of industry, for different platforms, to cover a wider variety and get a fairly objective final result,
meaning there were mobile, desktop and web application projects from categories such as develop-
ment, entertainment, research, biology and more. Projects were mostly found on Githubs top Java
open source projects and the end result of some of the most complex applications can be seen in the
table below.

Relations before Relations after Inherited relations Extended Implemented


JDT
AWS SDK for Java 34108 58803 24909 8969 15940
Geoserver 15782 19121 3706 2626 1080
Elasticsearch 14145 17851 3990 2701 1289
Ultimate Android 9287 12106 2951 2179 772
Openmicroscopy 10775 11652 1001 663 338
CoreNLP 6727 8217 1982 863 1119
J2ObjC 6372 8106 2020 1449 571
Buck (Android) 6111 8069 2190 1141 1049
Activiti 6303 7988 1711 1014 697
Pinpoint 5760 7311 1794 532 1262
Openfire 5390 6426 1116 602 514
Libgdx (Android) 4290 5740 1678 1197 481
H2o-3 2807 4240 1561 1432 129
Apollo 1287 1740 453 416 37

Table 3 : Several different projects results table


AWS SDK for Java is an easy to use software development kit for amazon web services that helps
simplify coding by providing Java APIs. Based on data in Table 3 it has huge amount of inherited
relations (24.909) from which bigger part takes implemented ones (15.940) than extended (8.969). Be-
cause this application is made for web service it is logical conclusion that there is bigger number of
implemented relations than extended. It is a result of user interface inheritance in most Java web
applications. Geoserver is an open source server for sharing geospatial information. It allows great
flexibility in map creation and data sharing. Rfind showed 3.706 inherited relations, with more ex-
tended than implemented because servers do not need lots of user interface compared to the rest of
inheritance. Elasticsearch is an analytic and text search engine that can process big volumes of data
fast an in near real time. It is mostly used as engine for complex and powerful applications. Elas-
tisearch has more than double extended compared to implemented relations which is normal behavior
for search engines, they inherit big amount of methods from other classes to create total search func-
tionality. Ultimate Android is a framework for rapid applications development, containing many
features like asynchronous networking, image loading, user interface effects etc. It is basically desk-
top application with more extended than implemented links, which is main characteristic of desktop
applications. They inherit big amount of other classes methods compared to user interface because
desktop Java applications do not have big needs for interface inheriting. Openmicroscopy develops
software and data format standards for storage and manipulation of biological light microscopy data.
ACM Transactions on Applied Perception, Vol. 2, No. 3, Article 1, Publication date: May 2010.
Analyzing relationships between classes in Java programme code 1:7

It is a desktop Java project involving multiple universities and research establishments in both Eu-
rope and USA. CoreNLP is Stanfords natural language software, that is an analysis tool for human
language that gives base forms of words, normalize dates, extract relations between entity mentions,
etc. Implemented links have a little bit higher count than extended ones because inheritance is mostly
of user interface, but count of inherited methods is not far away. J2ObjC is Googles command line tool
that translates Java code to Objective-C for iOS platform. It supports most Java language and runtime
features and is currently beta quality. Since it is a command line tool, it lacks interface and logically it
has a low number of implements. Buck is Facebooks build system that encourages creation of small
and reusable modules and supports many languages on many platforms, including Java. Activiti is a
desktop workflow and BPM (Business Process Management) platform for business people, developers
and system administrators that runs in any Java app, server or cluster. Pinpoint is an APM (Appli-
cation Performance Management) tool that helps analyzing the structure of a large-scale system and
how its components are interconnected, while having minimal impact on performance. As it monitors
and alters the system, it is expected to have a larger number of implemented relations. Openfire is
a RTC (Real Time Collaboration) server that uses XMPP protocol for instant messaging. It is simple
but offers solid security and performance. Libgdx is a framework for Java game development based
on OpenGL that works on multiple platforms and development environments like Eclipse, NetBeans
etc. As a development framework, there is a higher ratio of extended vs. implemented links. H2o-3
is a platform for scalable, distributed machine learning that uses familiar languages and works well
with big data tech. Successor to H2o-2, it allows developers to add data transformations and custom
algorithms. With little to no interface, its understandable for it to have over ten times more extended
relations. Apollo is a client for generating Java models from GraphQL queries that helps keep state-
ments organized and access from Java easy. With a lot of imported modules, Apollo has almost no
interface inheritance.

4. CONCLUSION
Software engineering is an extremely detailed and complex process that needs accurate intergraph and
subgraph relations analysis to properly function later on, and avoid additional correction costs. There-
fore it is needed for software analysis tools to stay toe to toe with software itself. Rfind greatly helps us
with Java programming language analysis, and by improving it, even more stable and reliant calcula-
tions and expectations can be achieved. After adding all the new functionalities regarding inheritance
relations recognition, one can use such information to predict how some elements of the software be-
have without any need to open softwares source code. The tool has potential for more further upgrades
and automation of some tasks which would have previously needed people.
In this project weve come to a conclusion that mobile and web applications written in Java
programming language often inherit more user interfaces than methods, so the keyword implements
appears more common than keyword extends. However, it is the other way around with desktop apps,
where inheritance mostly occurs via keyword extends than implements. Such situation was to be ex-
pected since mobile and web apps inherit different user interfaces while desktop apps mostly inherit
other classes functionalities.
REFERENCES
R. Milo, S. Shen-Orr, S. Itzkovitz, et al. Network motifs: simple building blocks of complex networks, Science 2002; 298:82427,
2002.
J. Petric and T. Galinac Grbac. Software structure evolution and relation to system defectiveness. In Proceedings of the 18th
International Conference on Evaluation and Assessment in Software Engineering EASE2014, London, UK, 2014.
J. Petric, T. Galinac Grbac, and M. Dubravac. Processing and data collection of program structures in open source repositories.
In Proceedings of SQAMIA 2014, pages 5766, Lovran, Croatia,2014.
ACM Transactions on Applied Perception, Vol. 2, No. 3, Article 1, Publication date: May 2010.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy