[go: up one dir, main page]

CN110908705B - Method for Establishing Mapping Relationship of Program Class Collections of Different Versions - Google Patents

Method for Establishing Mapping Relationship of Program Class Collections of Different Versions Download PDF

Info

Publication number
CN110908705B
CN110908705B CN201911138413.5A CN201911138413A CN110908705B CN 110908705 B CN110908705 B CN 110908705B CN 201911138413 A CN201911138413 A CN 201911138413A CN 110908705 B CN110908705 B CN 110908705B
Authority
CN
China
Prior art keywords
class
similarity
methods
classes
call
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911138413.5A
Other languages
Chinese (zh)
Other versions
CN110908705A (en
Inventor
陈星�
陈晓娜
胡传淑敏
郭莹楠
陈艳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fuzhou University
Original Assignee
Fuzhou University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fuzhou University filed Critical Fuzhou University
Priority to CN201911138413.5A priority Critical patent/CN110908705B/en
Publication of CN110908705A publication Critical patent/CN110908705A/en
Application granted granted Critical
Publication of CN110908705B publication Critical patent/CN110908705B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

本发明提出一种建立不同版本程序类集合映射关系的方法,首先,确定类相似度和方法相似度的评判因素;其次从源代码逆向工程建立类图;最后通过一系列的算法分析(包括计算初步类相似度、方法相似度以及迭代确立方法和类的最终相似度)建立不同版本间程序的类集合中类的“一对一”、“一对多”、“多对一”的映射关系以及类中方法的“一对一”映射。能够解决由于人工阅读源代码等方式寻找不同版本系统类集合间的映射关系难以实施的问题,直观反映系统的体系结构,增加了代码的可读性和可维护性,降低软件开发人员和维护人员理解不同版本间系统的难度,提供了一个在较高层次观察不同系统的方法。

Figure 201911138413

The present invention proposes a method for establishing a mapping relationship between classes of different versions of a program. First, the judging factors for class similarity and method similarity are determined; secondly, a class diagram is established from source code reverse engineering; finally, a series of algorithm analysis (including calculation Preliminary class similarity, method similarity, and iteratively establish the final similarity of methods and classes) to establish the "one-to-one", "one-to-many" and "many-to-one" mapping relationships of classes in the class set of programs between different versions And a "one-to-one" mapping of methods in a class. It can solve the problem that it is difficult to find the mapping relationship between different version system class sets due to manual reading of the source code, etc. It can directly reflect the system architecture, increase the readability and maintainability of the code, and reduce software developers and maintainers. Understanding the difficulty of systems across versions provides a way to look at different systems at a high level.

Figure 201911138413

Description

Method for establishing mapping relation of program class sets of different versions
Technical Field
The invention belongs to the technical field of computer software, and particularly relates to a method for establishing class set mapping relations of programs of different versions, particularly Java programs.
Background
Object-oriented technology has been a focus of research since its introduction. To date, object-oriented approaches have gradually penetrated various levels and aspects of software development, emerging as object-oriented approaches including object-oriented analysis, design, and programming. Software evolution refers to the process by which software is ramped and brought to a desired morphology. Software evolution plays an important role in prolonging the service life of software, the efficiency of software programs is improved after the software programs are evolved, and defects are corrected. Software maintenance and evolution are inevitable, but sometimes project personnel do not only want to obtain the evolved programs, and more, they desire to obtain the differences of the programs of different versions after the evolution. The evolution analysis of the software can help to comprehensively understand the program differences of different versions, the comprehensive understanding of the programs of the versions and the comprehensive understanding of the program differences of the different versions are the basis of program maintenance, however, the evolved programs have huge code quantity due to complex and linked structures, and the mode of analyzing the program evolution information by reading the source codes is a difficult and unwise behavior.
Although object-oriented technology has significantly improved the maintainability of programs, since the evolution analysis of different versions of programs at present needs to resort to development documents or change records of different versions of programs, the lack, incompleteness and inconsistency of normalized documents are common problems. Therefore, how to extract the high-level structure information of each version from the software programs of different versions under the condition of lacking of such documents is achieved, the mapping relation between the software programs of different versions is established according to the high-level structure information, and the difference between the software programs of different versions is obtained according to the mapping relation, so that the development of the high-level evolution information of the software programs becomes a troublesome problem in the software evolution analysis process.
Disclosure of Invention
In view of the deficiencies of the prior art, the technical problem to be solved by the present invention is to provide a method for establishing class set mapping relationships of different versions of programs, especially Java programs, wherein given two versions of source codes before and after the evolution of a Java program, the mapping relationships of "one-to-one", "one-to-many", "many-to-one" of classes in class sets of Java programs of old and new versions and the "one-to-one" mapping relationships of methods in method sets can be obtained.
In the scheme of the invention, firstly, judging factors of class similarity and method similarity are determined; secondly, establishing a class diagram from the reverse engineering of the source code, for example, analyzing the Java source code by a code analysis tool root to obtain an analyzed product, establishing models of classes in class sets of Java programs of different versions, and generating the class diagram; and finally, establishing the mapping relation of one-to-one, one-to-many and many-to-one of the classes in the class set of the Java program between different versions and the one-to-one mapping of the methods in the classes through a series of algorithm analysis (including calculating the initial class similarity, the method similarity and iteratively establishing the final similarity of the methods and the classes).
The method comprises the following specific steps:
a method for establishing a mapping relation of program class sets of different versions is characterized by comprising the following steps:
step S1: acquiring source codes of two different versions of the same program;
step S2: obtaining data structure information and the relation between classes and calling relation between methods in the classes according to the source codes of the two different versions in the step 1 through code analysis, and generating a class diagram;
step S3: calculating the primary class similarity: establishing model information of two version program class sets through the information obtained in the step S2, taking the class set of one version program as a class set A, calculating the similarity through a predefined class similarity evaluation factor, and determining the similarity of each class of the class set A under the class similarity evaluation factor of each class in a mapped version program class set B;
step S4: calculating the similarity of the method: establishing model information of two version method sets through the information obtained in the step S2, taking the method set of one version program as a method set A, calculating the similarity through a predefined method similarity evaluation factor, and determining the similarity of each method in a mapped version program method set B to each method in the method set A under the method similarity evaluation factor;
step S5: establishing a mapping relation: taking the method pair with the highest similarity, and establishing 'one-to-one' mapping of the methods; and according to the mapping relation of the method, adjusting the similarity of the classes in a step-by-step iteration mode, and finally determining the similarity between the classes.
Preferably, the program is a Java program.
Preferably, the class similarity evaluation factor includes: class name, attribute number, method number, similar attribute ratio and similar method ratio; the similarity evaluation factors of the method comprise: similarity between two classes to which the methods belong, frequency of calling the methods, frequency of calling other methods by the methods, method occupation ratio of mapping relations existing in a method set calling the two methods, and method occupation ratio and method signature of mapping relations existing in a method set called by the two methods.
Preferably, step S2 specifically includes:
step S21: definition of
Definition 1: CLASS set CLASS = { CLASS for a given program1, Class2, ..., Classn };
Wherein, ClassiIs the ith class of the program; represented as a triplet: classi = < className, FIELD, METHOD >(ii) a className represents the name of the class, FIELD represents all attribute sets of the current class, and METHOD represents all METHOD sets of the current class;
definition 2: attribute set FIELD = { FIELD of any one class1, Field2, ..., Fieldn };
Wherein, the FilediIs the ith attribute of the current class; represented as a triplet: fieldi =< fieldModifier, fieldType, fieldName >The fieldModifier is the authority of the attribute, the fieldType is the type of the attribute, and the fieldName is the name of the attribute;
definition 3: METHOD set of any one class = { METHOD = { METHOD }1, Method2, ..., Methodn };
Wherein, MethodiIs the ith method of the current class; represented as a quadruple: method for producing a metal oxide layeri = < methodModifier, methodReturnType, methodName, METHODPARAM>Method modifier indicates method authority, method Return type indicates return value type of method, method name indicates name of method, METHODPARAM = { methodParam =1, methodParam2, ..., methodParamnDenotes a parameter list set of the method, any one method paramjJ-th form showing the methodGinseng;
definition 4: similarity simClass = { sc) of new and old versions11, sc21, ..., scmn };
Wherein, for any scijStored in key-value pair format, with key format classi .className<-> classjclassName, corresponding to a class with a new versioniClass with old versionjThe similarity of (2);
definition 5: a method call Tree = (M, R) representing a call relationship of a method when a program runs, where M = { M = (M, R) }1, m2, ..., mnR is the set of method nodes, and R is the set of method invocation edges; each edge rije.R represents a number from miTo mjOf which the weight represents miCalling mjThe frequency of (d); for arbitrary miIn presence of mi.calli = { calli1, calli2, ..., callinDenotes calling miThe method set of (1); exist mi.becalli = { becalli1, becalli2, ..., becallimDenotes miA set of methods to invoke;
definition 6: similarity simMETHOD = { sm) of new and old version methods11, cm21, ..., smmn };
Wherein, for any smijStoring in the form of key value pairs with a key format of mi<-> mjMethod m with a new version corresponding to the valueiMethod m with old versionjThe similarity of (2);
step S22: handling class names
I/define class Linked List
Chain<SootClass> classes = null;
V/load all classes, put class linked list classes = scene.v ().getapplicationclasses ();
// define class iterator
Iterator<SootClass> iterator = classes.iterator();
while(iterator.hasNext())
do{
SootClass = iterator
Class ci= new ClassStructure (),/store in ClassStructure class form
String classname = SootClass
If the class is not the class of the analyzed Java program, then no record is made
if(!classname.contains(packagename)) continue;
ci.className=classname;
}
setList(CLASS,ci);
Step S23: handling attributes
Extracting attribute information for each class of a class set
for(ci:CLASS){
V/define Attribute information iterator, load class Attribute information and traverse
Iterator<SootField> fieldIteratorerator = ci.getFields().iterator();
while(fieldIteratorerator.hasNext())
do{
Sootfields = field
Stringname = s.getName (), attribute name type = s.getType (), toString (), attribute type int modifiers = s.getModifiers (), attribute rights ()
// return value 0: defaulting; returning the value 1: public; return value 2: a private; return value 4: protected
// store in the form of a FieldStructure class
Field fij = new FieldStructure();
fij.fieldModifiers=String.valueOf(modifiers); fij.fieldType=type; fij.fieldName=name; ci.FIELD.add(fij) Storage ofiAttribute information of class }
}
Step S24: processing method
Extracting method information of each of class set/interface set
for(ci:classlist||ci:interfacelist){
I/define method information iterator, load class method information and traverse
Iterator<SootMethod> methodIterator = ci.getMethods().iterator();
while(methodIterator.hasNext())
do{
Sootmethods = methoditerator. next (),/method information data structure
int modifiers = s.getModifiers (),/method permission Type = s.getTreturnType (),/Return Type
String name = s.getName (),/method name List < Type > paramTypes = s.getParameterTypes (),/parameter List
// store in the form of a method Structure class
Method mij = new MethodStructure(); mij.methodModifiers=String.valueOf(modifiers); mij.methodReturnType=String.valueOf(returntype); mij.methodName=name;
// parameters for the process should be stored separately
for(Type ttemp:paramTypes)
mij.METHODPARAM.add(String.valueOf(ttemp));
ci.METHOD.add(mij) Storage ofiClass method information }
}
Step S25: handling inheritance relationships
// defining inheritance relationship storage Structure
List<String> entenders=new ArrayList<>();
// obtaining a parent class of a class
SootClass superclass = ci.getSuperclass();
// Format: father-subclass
extenders.add(superclass.getName()+"<|--" + ci.getName());
Step S26: processing implementation relationships
// define implementation relationship storage Structure
List<String> implements=new ArrayList<>();
Interface for obtaining certain class (class can realize multiple interfaces in Java program, Chain is adopted for storage)
Chain<SootClass> iChain = ci.getInterfaces();
// generating iterator
Iterator<SootClass> iIterator = iChain.iterator();
while(iIterator .hasNext())
do{
SootClass interfaceclass = iIterator.next();
implememts.add(interfaceclass.getName()+"<|.." + ci.getName());
}
Step S27: handling associative relations
// define association store Structure
List<SootClass> r11s= new ArrayList<>();
List<SootClass> r1ns =new ArrayList<>();
V/determining whether there is an association
if (ci.Fieldik.fieldType.contains(packagename)) then
{
// determining whether or not it is 1 to many
if (ci.Fieldik.fieldType.contains("[]"))
r1ns.add( ci.getName() + "1--1..*" + fieldType);
else
r11s.add( ci.getName() + "1--1" + fieldType);
}
Step S28: handling dependencies
// definition dependency storage architecture
List<String> relys=new ArrayList<>();
// obtaining dependencies
for(String s:method_invoke){
String uml= s.split("->")[0].split(":")[0]+" ..>"+s.split("->")[1].split(":")[0];
if(!relys.contain(uml))then
relys.add(uml);
}
Step S29: handling call relation trees
The first step is as follows:
UL ij←Uijgetvalue (),/DeUijThe left half of the ValueBox
UR ij←UijGetvalue (),/DeUijThe right half of the ValueBox
The second step is that:
if (UijgetClass () = = JAssignStmt) the// if an assignment statement
{
// Presence method Call
if ( UR ij.toString() == JSpecialInvokeExpr.class ||
UR ij.toString() == JVirturalInvokeExpr.class ||
UR ij.toString() == JInterfaceInvokeExpr.class ||
UR ij.toString() == JStaticInvokeExpr.class) then
{
// obtaining called method
invokeMethod<—Uij.getMethod().getSignature();
invokek<—" Mi ->invokeMethod;/record call information
INVOKE.add(invokek);
}
}
else if (UijgetClass () = = JInvokeStmt) the// if call statement
{
if( Uij.toString().contains(“specialinvoke”)||
Uij.toString().contains(“virtualinvoke”)||
Uij.toString().contains(“interfaceinvoke”)||
Uij.toString().contains(“staticinvoke”))then
{
// obtaining called method
invokeMethod<—Uij.getMethod().getSignature();
invokek<—" Mi ->invokeMethod;/record call information
INVOKE.add(invokek);
}
}
The third step:
// construction InvokeTree
for(invokek:INVOKE)
1. Generate(invokek)。
Preferably, the step of calculating the similarity according to the predefined class similarity evaluation factor in step S3 specifically includes the following steps:
classiAnd classjClass name, attribute number, method number, similar attribute ratio, similar method ratio 5 judging factors for calculating classiAnd classjSimilarity of (2):
Figure DEST_PATH_IMAGE002
Figure DEST_PATH_IMAGE004
Figure DEST_PATH_IMAGE006
Figure DEST_PATH_IMAGE008
Figure DEST_PATH_IMAGE010
Figure DEST_PATH_IMAGE012
wherein, fnumiIs classiNumber of middle attributes, fnumjIs classjNumber of middle attributes, mnumiIs classiNumber of methods in (1), mnumjIs classjNumber of methods (1), fnumijIs classiAnd classjNumber of equal attributes in the set, mnumijIs classiAnd classjNumber of same methods in the same way.
Preferably, the step of calculating the similarity through the predefined method similarity evaluation factor in the step S4 specifically includes the following steps:
by the method miAnd mjSimilarity between the two classes to which the method belongs, number of times the method is called, number of times the method calls other methods, call miM of the method setiCall and call mjM of the method setjMethod contrast ratio, m, with a mapping relationship in calliSet of called methods miBecall and mjSet of called methods mjMethod-to-contrast ratio and method signature 6 judgment factor calculation method m with mapping relationship in becalliAnd mjSimilarity of (2):
Figure DEST_PATH_IMAGE014
Figure DEST_PATH_IMAGE016
Figure DEST_PATH_IMAGE018
Figure DEST_PATH_IMAGE020
Figure DEST_PATH_IMAGE022
Figure DEST_PATH_IMAGE024
Figure DEST_PATH_IMAGE026
Figure DEST_PATH_IMAGE028
Figure DEST_PATH_IMAGE030
wherein becallmijIs miBecall and mjThe number of pairs of methods having a mapping relationship in becall, becallnumijIs miBecall or mjNumber of elements of bell, callmijIs miCall and mjThe method for the existence of the mapping relation in the call is to the number, callnumijIs miCall or mjThe number of elements of call.
Preferably, step S5 specifically includes:
the method pair with the highest similarity is selected, one-to-one mapping of the method is established, the similarity of the classes is adjusted step by step through the mapping relation of the method, the similarity between the classes is updated in a step-by-step iteration mode, when the mapping relation is determined by the last method, the similarity of the classes is finally determined, a threshold value is determined, the mapping relation of the classes is established, and the one-to-one mapping relation or the one-to-many mapping relation or the many-to-one mapping relation of the classes is finally obtained.
Preferably, step S5 is specifically realized by the following algorithm:
Data: number of methods in the new version:Nnum,number of methods in the old version:Onum, simCLASS, simMETHOD
Result: method mapping set methodMap, class mapping set classMap
while--Nnum>= 0 do
smij = max{simMETHOD);
methodMap.put(methodi <—> methodj,smij);
scij=(scij+ 1)/2;
for p in Nnum do
for q in Onum do
if methodi ∈methodp.call and methodj∈methodq,call then
callmpq++
end
if methodi ∈methodp.becall and methodj∈methodq,becall then
becallmpq++
end
end
end
update(simMETHOD)
end
if scij>=0.8 then
classMap.put(classi <—> classj,scij);
end。
the invention and its preferred embodiments have the following advantageous properties:
1. effectiveness: for different versions of source codes of a given Java program, the mapping relation, the similarity of classes, the mapping relation of methods and the mapping relation of class sets of the same class can be obtained.
2. The accuracy is as follows: for the calculated class similarity, obtaining class similarity by using class names, attribute numbers, method number attribute information and method information, wherein the similarity of classes with a certain mapping relation before and after evolution should have higher similarity, and the similarity of classes without the mapping relation should not be higher than the similarity between classes with the mapping relation; for the obtained method mapping relation, the found method one-to-one mapping relation is consistent with the mapping relation obtained by directly observing the source code; and for the obtained class set mapping relation, the found mapping relation is ensured to be consistent with the mapping relation obtained by directly observing the source code.
3. Universality: for given different Java programs, the mapping relation of the method and the mapping relation of the class set can be obtained.
The method comprises the steps of analyzing Java source codes through a code analysis tool root, obtaining analyzed products, establishing models of different types of classes in class sets of Java programs of different versions, then establishing one-to-one, one-to-many and many-to-one mapping relations of the classes in the class sets of the Java programs of the different versions through a series of operations, solving the problem that finding the mapping relations among the class sets of the systems of the different versions in a mode of manually reading the source codes and the like is difficult to implement, visually reflecting the system structure of the system, increasing the readability and maintainability of the codes, reducing the difficulty of software developers and maintainers in understanding the systems of the different versions, and providing a method for observing the systems of the different versions at a higher level.
Drawings
The invention is described in further detail below with reference to the following figures and detailed description:
FIG. 1 is a schematic overall flow diagram of an embodiment of the present invention;
FIG. 2 is a schematic diagram of a mapping algorithm according to an embodiment of the present invention;
FIG. 3 is a schematic view of a user input interface of an embodiment of the present invention;
FIG. 4 is a schematic diagram of an output of a version A class diagram of a car rental system for version evaluation according to an embodiment of the invention;
FIG. 5 is a schematic diagram of a version B class diagram output of a car rental system for version evaluation according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating class mapping results according to an embodiment of the present invention
FIG. 7 is a diagram illustrating a mapping result according to an embodiment of the present invention.
Detailed Description
In order to make the features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail as follows:
firstly, the implementation of the present embodiment takes the definition of the evaluation factor as the basis, including: and defining evaluation factors of class similarity and method similarity, such as class name, attribute number, attribute information, method number, method information, calling relationship, similarity between classes to which the methods belong, calling times of the methods, called times of the methods and the like.
As shown in fig. 1, the scheme flow provided by this embodiment includes the following steps:
step S1: acquiring source codes of two different versions of the same Java program; for example, given a typical object-oriented Java program, the Java program source code can be analyzed by the code analysis tool root;
step S2: analyzing data structure information in the root and calling logic information between classes corresponding to the Java program classes, wherein the data structure information comprises a class name list, a member variable table, a member method table, a parent class and an interface list. Wherein the member variable information includes: attribute name, type, permission information, whether it is declared in a class, etc.; the information of the member method includes: method name, parameter type list, return value type, authority information, and type for declaring the method; and meanwhile, acquiring static relations (including implementation relations, inheritance relations and association relations) between classes, calling relations (dependency relations) between methods and methods in the classes, and the like, and generating a class diagram through the acquired information.
Step S3: calculating the primary class similarity: establishing model information of two versions of Java program class sets through the information obtained in the step S2, taking the class set of one version of Java program as a class set A, calculating the similarity through predefined class similarity evaluation factors, and determining the similarity of a certain class B in the mapped version of Java program class set B to each class in the class set A under the class similarity evaluation factors;
step S4: calculating the similarity of the method: establishing model information of two version method sets through the information obtained in the step S2, taking a method set of one version Java program as a method set A, calculating similarity through a predefined method similarity evaluation factor, and determining the similarity of a certain method B in a method set B of the mapped version Java program to each method of the method set A under the method similarity evaluation factor;
step S5: the method pair with the highest similarity is taken, and the one-to-one mapping of the methods is established. The similarity of the classes is gradually adjusted through the mapping relation of the method, the similarity between the classes is finally determined through a gradual iteration mode, and finally three kinds of mapping relations of the classes are obtained.
Specifically, the specific implementation thereof comprises:
1 detailed construction of the protocol of this example
1.1 defining class similarity evaluation factor and method similarity evaluation factor
Definition class similarity evaluation factor
In this embodiment, 5 classes of static features are selected as the factors for class similarity evaluation, which are:
1. a class name; 2. the number of attributes; 3. the number of the methods; 4. similar attribute ratio; 5. similar methods are used.
(II) defining method similarity evaluation factor
In this embodiment, 4 pieces of information obtained by simulating system operation, static information (method signature) of the method, and similarity of the method category are selected as factors for judging similarity of the method. (We believe that the method should have only a "one-to-one" mapping)
1. Similarity between the two classes to which the method belongs; 2. the frequency at which the method is invoked; 3. the frequency with which the method calls other methods; 4. calling method contrast of mapping relation in method set of the two methods; 5. the method comparison of the mapping relation exists in the method set called by the two methods; 6. method signature (authority of method, return value type, method name, parameter list type of method).
1.2 obtaining information and generating class diagrams
1.2.1 Definitions
Definition 1: CLASS set CLASS = { CLASS for a given program1, Class2, ..., Classn }。
Wherein, ClassiIs the ith class of programs, which can be represented as a triple: classi = < className, FIELD, METHOD >. className represents the name of the class, FIELD represents the set of all the attributes of the current class, and METHOD represents the set of all the METHODs of the current class.
Definition 2: attribute set FIELD = { FIELD of any one class1, Field2, ..., Fieldn }。
Wherein, the FilediIs the ith attribute of the current class, which can be represented as a triple: fieldi =< fieldModifier, fieldType, fieldName >The fieldModifier is the authority of the attribute, the fieldType is the type of the attribute, and the fieldName is the name of the attribute.
Definition 3: METHOD set of any one class = { METHOD = { METHOD }1, Method2, ..., Methodn }。
Wherein, MethodiThe ith method, which is a current class, can be represented as a quadruple: method for producing a metal oxide layeri = < methodModifier, methodReturnType, methodName, METHODPARAM>Method modifier indicates method authority, method Return type indicates return value type of method, method name indicates name of method, METHODPARAM = { methodParam =1, methodParam2, ..., methodParamnDenotes a parameter list set of the method, any one method paramjThe jth argument of the method is shown.
Definition 4: similarity simClass = { sc) of new and old versions11, sc21, ..., scmn }。
Wherein, for any scijStoring in key-value pair format (key format class)i .className<-> classjclassName, corresponding to a class with a new versioniClass with old versionjSimilarity of (d).
Definition 5: method call Tree = (M, R), which represents the call relationship of the method when the system runs, where M = { M = (M, R) }1, m2, ..., mnIs the set of method nodes, and R is the set of method call edges. Each edge rije.R represents a number from miTo mjOf which the weight represents miCalling mjOf (c) is detected. For arbitrary miIn presence of mi.calli = { calli1, calli2, ..., callinDenotes calling miA method set of (1). Exist mi.becalli = { becalli1, becalli2, ..., becallimDenotes miA set of methods to invoke.
Definition 6: similarity simMETHOD = { sm) of new and old version methods11, cm21, ..., smmn }。
Wherein, for any smijStoring in key value pair form (key format is m)i<-> mjMethod m with a new version corresponding to the valueiMethod m with old versionjSimilarity of (d).
1.2.2 flow Steps
Class (I) name
I/define class Linked List
Chain<SootClass> classes = null;
V/load all classes, put class linked list classes = scene.v ().getapplicationclasses ();
// define class iterator
Iterator<SootClass> iterator = classes.iterator();
while(iterator.hasNext())
do{
SootClass = iterator
Class ci= new ClassStructure (),/store in ClassStructure class form
String classname = SootClass
If the class is not the class of the analyzed Java program, then no record is made
if(!classname.contains(packagename)) continue;
ci.className=classname;
}
setList(CLASS,ci);
(II) Properties
Extracting attribute information for each class of a class set
for(ci:CLASS){
V/define Attribute information iterator, load class Attribute information and traverse
Iterator<SootField> fieldIteratorerator = ci.getFields().iterator();
while(fieldIteratorerator.hasNext())
do{
Sootfields = field
Stringname = s.getName (), attribute name type = s.getType (), toString (), attribute type int modifiers = s.getModifiers (), attribute rights ()
// return value 0: defaulting; returning the value 1: public; return value 2: a private; return value 4: protected
// store in the form of a FieldStructure class
Field fij = new FieldStructure();
fij.fieldModifiers=String.valueOf(modifiers); fij.fieldType=type; fij.fieldName=name; ci.FIELD.add(fij) Storage ofiAttribute information of class }
}
(III) method
Extracting method information of each of class set/interface set
for(ci:classlist||ci:interfacelist){
I/define method information iterator, load class method information and traverse
Iterator<SootMethod> methodIterator = ci.getMethods().iterator();
while(methodIterator.hasNext())
do{
Sootmethods = methoditerator. next (),/method information data structure
int modifiers = s.getModifiers (),/method permission Type = s.getTreturnType (),/Return Type
String name = s.getName (),/method name List < Type > paramTypes = s.getParameterTypes (),/parameter List
// store in the form of a method Structure class
Method mij = new MethodStructure(); mij.methodModifiers=String.valueOf(modifiers); mij.methodReturnType=String.valueOf(returntype); mij.methodName=name;
// parameters for the process should be stored separately
for(Type ttemp:paramTypes)
mij.METHODPARAM.add(String.valueOf(ttemp));
ci.METHOD.add(mij) Storage ofiClass method information }
}
(IV) inheritance relationship
// defining inheritance relationship storage Structure
List<String> entenders=new ArrayList<>();
// obtaining a parent class of a class
SootClass superclass = ci.getSuperclass();
// Format: father-subclass
extenders.add(superclass.getName()+"<|--" + ci.getName());
(V) implementation relationship
// define implementation relationship storage Structure
List<String> implements=new ArrayList<>();
Interface for obtaining certain class (class can realize multiple interfaces in Java program, Chain is adopted for storage)
Chain<SootClass> iChain = ci.getInterfaces();
// generating iterator
Iterator<SootClass> iIterator = iChain.iterator();
while(iIterator .hasNext())
do{
SootClass interfaceclass = iIterator.next();
implememts.add(interfaceclass.getName()+"<|.." + ci.getName());
}
(VI) Association relationship
// define association store Structure
List<SootClass> r11s= new ArrayList<>();
List<SootClass> r1ns =new ArrayList<>();
V/determining whether there is an association
if (ci.Fieldik.fieldType.contains(packagename)) then
{
// determining whether or not it is 1 to many
if (ci.Fieldik.fieldType.contains("[]"))
r1ns.add( ci.getName() + "1--1..*" + fieldType);
else
r11s.add( ci.getName() + "1--1" + fieldType);
}
(VII) dependency relationship
// definition dependency storage architecture
List<String> relys=new ArrayList<>();
// obtaining dependencies
for(String s:method_invoke){
String uml= s.split("->")[0].split(":")[0]+" ..>"+s.split("->")[1].split(":")[0];
if(!relys.contain(uml))then
relys.add(uml);
}
(eighth) calling relationship Tree
The first step is as follows:
UL ij←Uijgetvalue (),/DeUijThe left half of the ValueBox
UR ij←UijGetvalue (),/DeUijThe right half of the ValueBox
The second step is that:
if (UijgetClass () = = JAssignStmt) the// if an assignment statement
{
// Presence method Call
if ( UR ij.toString() == JSpecialInvokeExpr.class ||
UR ij.toString() == JVirturalInvokeExpr.class ||
UR ij.toString() == JInterfaceInvokeExpr.class ||
UR ij.toString() == JStaticInvokeExpr.class) then
{
// obtaining called method
invokeMethod<—Uij.getMethod().getSignature();
invokek<—" Mi ->invokeMethod;/record call information
INVOKE.add(invokek);
}
}
else if (UijgetClass () = = JInvokeStmt) the// if call statement
{
if( Uij.toString().contains(“specialinvoke”)||
Uij.toString().contains(“virtualinvoke”)||
Uij.toString().contains(“interfaceinvoke”)||
Uij.toString().contains(“staticinvoke”))then
{
// obtaining called method
invokeMethod<—Uij.getMethod().getSignature();
invokek<—" Mi ->invokeMethod;/record call information
INVOKE.add(invokek);
}
}
The third step:
// construction InvokeTree
for(invokek:INVOKE)
Generate(invokek)
1.3 calculate class similarity
ClassiAnd classjClass name, attribute number, method number, similar attribute ratio, similar method ratio 5 judging factors for calculating classiAnd classjSimilarity of (2):
Figure 564633DEST_PATH_IMAGE002
Figure 871986DEST_PATH_IMAGE004
Figure 543401DEST_PATH_IMAGE006
Figure 266506DEST_PATH_IMAGE008
Figure 500785DEST_PATH_IMAGE010
Figure 182302DEST_PATH_IMAGE012
wherein, fnumiIs classiNumber of middle attributes, fnumjIs classjNumber of middle attributes, mnumiIs classiNumber of methods in (1), mnumjIs classjNumber of methods (1), fnumijIs classiAnd classjNumber of equal attributes in the set, mnumijIs classiAnd classjNumber of same methods in the same way.
1.4 method of calculating similarity
By the method miAnd mjSimilarity between the two classes to which the method belongs, number of times the method is called, number of times the method calls other methods, call miM of the method setiCall and call mjM of the method setjMethod contrast ratio, m, with a mapping relationship in calliSet of called methods miBecall and mjSet of called methods mjMethod-to-contrast ratio and method signature 6 judgment factor calculation method m with mapping relationship in becalliAnd mjSimilarity of (2):
Figure 137751DEST_PATH_IMAGE014
Figure 133389DEST_PATH_IMAGE016
Figure 425437DEST_PATH_IMAGE018
Figure 809013DEST_PATH_IMAGE020
Figure 189442DEST_PATH_IMAGE022
Figure 457612DEST_PATH_IMAGE024
Figure 43314DEST_PATH_IMAGE026
Figure 535475DEST_PATH_IMAGE028
Figure 954866DEST_PATH_IMAGE030
wherein becallmijIs miBecall and mjThe number of pairs of methods having a mapping relationship in becall, becallnumijIs miBecall or mjNumber of elements of bell, callmijIs miCall and mjThe method for the existence of the mapping relation in the call is to the number, callnumijIs miCall or mjThe number of elements of call.
1.5 mapping Algorithm
The method pair with the highest similarity is taken, and the one-to-one mapping of the methods is established. The similarity of classes is gradually adjusted through the mapping relation of the methods, the similarity between the classes is updated through a gradual iteration mode, when the mapping relation is determined by the last method, the similarity of the classes is finally determined, a threshold value is determined, the mapping relation of the classes is established, and the one-to-one mapping relation, the one-to-many mapping relation and the one-to-many mapping relation of the classes are finally obtained. The specific mapping algorithm is shown in fig. 2.
2 mode of use
The scheme of the embodiment uses an integrated development tool IntelliJ IDEA, and is developed based on Java language.
(1) Before using the method of the embodiment, firstly, the method code is imported into the working interval: placing the two versions of system source code into the src directory as prompted by the user input interface in fig. 3, and modifying PACKAGENAME1 and PACKAGENAME2 of the user input interface according to the package name;
(2) and running the program under the condition of ensuring that no error exists in the first step, and automatically acquiring all relevant information by the method of the embodiment and generating the class diagrams of two versions. And simultaneously displaying the class set mapping relation and the method set mapping relation of the two versions.
3 test example
3.1 class diagram evaluation
Completeness: for a given Java program source code, information such as a class name, attribute authority, attribute type, attribute name, method authority, method return type, method name, method parameter list, class relationship (inheritance, implementation, association, dependency) and the like can be acquired.
Universality: the relevant information can be obtained for given different Java program source codes.
Two versions of a car rental system were used for evaluation, and the class diagram output is shown in fig. 4 and 5:
3.2 class Collection and method Collection mapping evaluation
Effectiveness: for different versions of source codes of a given Java program, the mapping relation, the similarity of classes, the mapping relation of methods and the mapping relation of class sets of the same class can be obtained.
The accuracy is as follows: for the calculated class similarity, obtaining class similarity by using class names, attribute numbers, method number attribute information and method information, wherein the similarity of classes with a certain mapping relation before and after evolution should have higher similarity, and the similarity of classes without the mapping relation should not be higher than the similarity between classes with the mapping relation; for the obtained method mapping relationship, it should be ensured that the found method one-to-one mapping relationship is consistent with the mapping relationship obtained by directly observing the source code; for the obtained class set mapping relationship, it should be ensured that the found mapping relationship is consistent with the mapping relationship obtained by directly observing the source code.
Universality: for given different Java programs, the mapping relation of the method and the mapping relation of the class set can be obtained.
The evaluation was performed using the two versions of the system described above, and the results are shown in fig. 6 and 7.
The obtained method mapping relation and the class set mapping relation are applied to the class diagram, the fact that the class diagram of the version 1 can be converted into the class diagram of the version 2 under the action of the mapping relation can be observed, meanwhile, the result of manually observing the source code is consistent with the result obtained by the method, and the limitation, the accuracy and the universality of the method can be met.
The present invention is not limited to the above preferred embodiments, and various other methods for creating the mapping relationship between different versions of program sets can be derived by anyone based on the teaching of the present invention.

Claims (4)

1.一种建立不同版本程序类集合映射关系的方法,其特征在于,包括以下步骤:1. a method for establishing different version program class set mapping relationship, is characterized in that, comprises the following steps: 步骤S1:获取同一程序两个不同版本的源代码;Step S1: obtaining source codes of two different versions of the same program; 步骤S2:根据步骤1的两个不同版本的源代码通过代码分析获取数据结构信息和类与类之间的关系,以及类中方法与方法间的调用关系,生成类图;Step S2: According to the source codes of the two different versions of step 1, the data structure information, the relationship between classes and the classes, and the calling relationship between the methods in the classes are obtained through code analysis, and a class diagram is generated; 步骤S3:计算初步类相似度:通过步骤S2获得的信息建立两个版本程序类集合的模型信息,以其中一个版本程序的类集合为类集合A,通过预定义的类相似度评判因素计算相似度,确定被映射版本程序类集合B中每个类在类相似度评判因素下对类集合A每个类的相似度;Step S3: Calculate the preliminary class similarity: establish model information of two version program class sets based on the information obtained in step S2, take the class set of one version program as the class set A, and calculate the similarity according to the predefined class similarity evaluation factors. degree, determine the similarity of each class in the mapped version program class set B to each class in the class set A under the class similarity evaluation factor; 步骤S4:计算方法相似度:通过步骤S2获得的信息建立两个版本方法集合的模型信息,以其中一个版本程序的方法集合为方法集合A,通过预定义的方法相似度评判因素计算相似度,确定被映射版本程序方法集合B中每个方法在方法相似度评判因素下对方法集合A每个方法的相似度;Step S4: Calculate the similarity of the method: establish the model information of the two version method sets based on the information obtained in the step S2, take the method set of one version program as the method set A, and calculate the similarity through the predefined method similarity evaluation factors, Determine the similarity of each method in the method set B of the mapped version to each method in the method set A under the method similarity evaluation factor; 步骤S5:建立映射关系:取具有最高相似度的方法对,建立方法的“一对一”映射;根据方法的映射关系,通过逐步迭代的方式调整类的相似度,并最终确定类间的相似度;Step S5: Establish a mapping relationship: take the method pair with the highest similarity, and establish a "one-to-one" mapping of methods; according to the mapping relationship of the methods, adjust the similarity of the classes through a step-by-step iteration, and finally determine the similarity between the classes Spend; 所述程序为Java程序;The program is a Java program; 步骤S2具体包括:Step S2 specifically includes: 步骤S21:定义Step S21: Definition 定义1:给定程序的类集合CLASS={Class1,Class2,...,Classn};Definition 1: The class set of a given program CLASS={Class 1 , Class 2 ,...,Class n }; 其中,Classi是程序的第i个类;表示为三元组:Classi=<className,FIELD,METHOD>;className表示类名,FIELD表示当前类的所有属性集合,METHOD表示当前类的所有方法集合;Among them, Class i is the i-th class of the program; it is represented as a triple: Class i =<className, FIELD,METHOD>; className represents the class name, FIELD represents the set of all attributes of the current class, and METHOD represents all the methods of the current class gather; 定义2:任意一个类的属性集合FIELD={Field1,Field2,...,Fieldn};Definition 2: The attribute set of any class FIELD={Field 1 , Field 2 ,..., Field n }; 其中,Filedi是当前类的第i个属性;表示为一个三元组:Fieldi=<fieldModifier,fieldType,fieldName>,fieldModifier是属性的权限,fieldType是属性的类型,fieldName是属性的名称;Among them, Filed i is the ith attribute of the current class; it is represented as a triple: Fieldi=<fieldModifier, fieldType, fieldName>, fieldModifier is the permission of the attribute, fieldType is the type of the attribute, and fieldName is the name of the attribute; 定义3:任意一个类的方法集合METHOD={Method1,Method2,...,Methodn};Definition 3: Method set of any class METHOD={Method 1 ,Method 2 ,...,Method n }; 其中,Methodi是当前类的第i个方法;表示为一个四元组:Methodi=<methodModifier,methodReturnType,methodName,METHODPARAM>,methodModifier表示方法权限,methodReturnType表示方法的返回值类型,methodName表示方法的名称,METHODPARAM={methodParam1,methodParam2,...,methodParamn}表示该方法的参数列表集合,任意一个methodParamj表示该方法的第j个形参;Among them, Method i is the ith method of the current class; it is represented as a four-tuple: Method i =<methodModifier, methodReturnType, methodName, METHODPARAM>, methodModifier represents the method authority, methodReturnType represents the return value type of the method, and methodName represents the method's Name, METHODPARAM={methodParam 1 , methodParam 2 ,..., methodParam n } represents the parameter list set of the method, any methodParam j represents the jth formal parameter of the method; 定义4:新旧版本类相似度simCLASS={sc11,sc21,...,scmn};Definition 4: Class similarity between old and new versions simCLASS={sc 11 ,sc 21 ,...,sc mn }; 其中,对于任意scij以键值对形式存储,键格式为classi.className<->classj.className,对应的值为新版本的类classi与旧版本的类classj的相似度;Wherein, for any sc ij stored in the form of key-value pairs, the key format is class i.className <->class j.className , and the corresponding value is the similarity between the new version of class class i and the old version of class class j ; 定义5:方法调用树Tree=(M,R),表示程序运行时方法的调用关系,其中M={m1,m2,...,mn}是方法节点集,R是方法调用边的集合;每个边缘rij∈R表示从mi到mj的方法调用,其权重表示mi调用mj的频率;对于任意的mi,存在mi.calli={calli1,calli2,...,callin}表示调用mi的方法集合;存在mi.becalli={becalli1,becalli2,...,becallim}表示mi调用的方法集合;Definition 5: Method call tree Tree=(M, R), which represents the calling relationship of methods when the program is running, where M={m 1 , m 2 ,..., m n } is the method node set, and R is the method call edge The set of ; each edge r ij ∈ R represents a method call from m i to m j , and its weight represents the frequency of m i calling m j ; for any m i , there is m i .call i ={call i1 ,call i2 ,...,call in } represents the method set for calling mi; there exists m i .becall i ={becall i1 ,becall i2 ,...,becall im } represents the method set called by mi ; 定义6:新旧版本方法相似度simMETHOD={sm11,cm21,...,smmn};Definition 6: Similarity of old and new versions of methods simMETHOD={sm 11 , cm 21 ,..., sm mn }; 其中,对于任意smij以键值对形式存储,键格式为mi<->mj,对应的值为新版本的方法mi与旧版本的方法mj的相似度;Among them, for any sm ij stored in the form of a key-value pair, the key format is m i <-> m j , and the corresponding value is the similarity between the method m i of the new version and the method m j of the old version; 步骤S22:处理类名,包括:Step S22: Process the class name, including: 定义类链表;define a linked list of classes; 加载所有类,放入类链表;Load all classes and put them into the class list; 定义类迭代器,包括:Define class iterators, including: 获取类数据结构SootClass;Get the class data structure SootClass; 获取类名;get class name; 若该class非被分析Java程序的class,则不记录;If the class is not the class of the Java program being analyzed, it will not be recorded; 将结果以ClassStructure class形式存储,并保存ci类的类信息;Store the result in the form of ClassStructure class, and save the class information of the c i class; 步骤S23:处理属性,包括:Step S23: Process attributes, including: 提取类集合每个类的属性信息;Extract the attribute information of each class in the class collection; 定义属性信息迭代器,加载类属性信息并遍历:Define an attribute information iterator, load class attribute information and traverse: 获取属性信息数据结构;Get the attribute information data structure; 获取属性名;get attribute name; 获取属性类型;get attribute type; 获取属性权限:Get attribute permissions: 返回值0:默认;返回值1:public;返回值2:private;返回值4:protected;Return value 0: default; return value 1: public; return value 2: private; return value 4: protected; 将结果以FieldStructure class形式存储,并保存ci类的属性信息;Store the result in the form of FieldStructure class, and save the attribute information of the c i class; 步骤S24:处理方法,包括:Step S24: a processing method, including: 提取类集合/接口集合每个的方法信息;Extract the method information of each class collection/interface collection; 定义方法信息迭代器,加载类方法信息并遍历,包括:Define method information iterator, load class method information and traverse, including: 获取方法信息数据结构;Get method information data structure; 获取方法权限;get method permission; 获取返回类型;get return type; 获取方法名;get method name; 获取参数列表;get parameter list; 对于方法的参数分个存储;The parameters of the method are stored separately; 将结果以MethodStructure class形式存储,并保存ci类的方法信息;Store the result in the form of the MethodStructure class, and save the method information of the c i class; 步骤S25:处理继承关系,包括:Step S25: Process the inheritance relationship, including: 定义继承关系存储结构;Define the inheritance relationship storage structure; 格式为:父类<|--子类;The format is: parent class<|--subclass; 获取某个类的父类并存储继承关系;Get the parent class of a class and store the inheritance relationship; 步骤S26:处理实现关系,包括:Step S26: Process the realization relationship, including: 定义实现关系存储结构;Define the implementation relational storage structure; 获取某个类的接口;Get the interface of a class; 生成迭代器并存储实现关系;Generate iterators and store implementation relationships; 步骤S27:处理关联关系,包括:Step S27: Process the association relationship, including: 定义关联关系存储结构;Define the relationship storage structure; 判断是否存在关联关系:Determine whether there is a relationship: 判断是否为1对1;Determine whether it is 1 to 1; 判断是否为1对多;Determine whether it is 1-to-many; 步骤S28:处理依赖关系,包括:Step S28: Process dependencies, including: 定义依赖关系存储结构;Define the dependency storage structure; 获取依赖关系;get dependencies; 步骤S29:处理调用关系树,包括以下步骤:Step S29: Process the calling relationship tree, including the following steps: 第一步:first step: 获得Uij.ValueBox左半部分;Get the left half of U ij .ValueBox; 获得Uij.ValueBox右半部分;Get the right half of U ij .ValueBox; 第二步:Step 2: 如果是赋值语句且存在方法调用,则:If it is an assignment statement and there is a method call, then: 获取被调用方法,并记录调用信息;Get the called method and record the call information; 如果是调用语句,则:If it is a call statement, then: 获取被调用方法,并记录调用信息;Get the called method and record the call information; 第三步:third step: 构造InvokeTree;Construct InvokeTree; 步骤S3当中通过预定义的类相似度评判因素计算相似度具体包括以下步骤:In step S3, calculating the similarity through the predefined class similarity evaluation factors specifically includes the following steps: 以类classi和classj的类名、属性个数、方法个数、相似属性占比、相似方法占比5个评判因素计算类classi和classj的相似度:The similarity between class i and class j is calculated by using the class names of class i and class j , the number of attributes, the number of methods, the proportion of similar attributes, and the proportion of similar methods. scij=0.1*r1ij+0.2*r2ij+0.2*r3ij+0.25*r4ij+0.25*r5ijsc ij =0.1*r 1ij +0.2*r 2ij +0.2*r 3ij +0.25*r 4ij +0.25*r 5ij ;
Figure FDA0003023504250000041
Figure FDA0003023504250000041
Figure FDA0003023504250000042
Figure FDA0003023504250000042
Figure FDA0003023504250000043
Figure FDA0003023504250000043
Figure FDA0003023504250000044
Figure FDA0003023504250000044
Figure FDA0003023504250000045
Figure FDA0003023504250000045
其中,fnumi为classi中属性的数量,fnumj为classj中属性的数量,mnumi为classi中方法的数量,mnumj为classj中方法的数量,fnumij为classi与classj中相同属性的个数,mnumij为classi与classj中相同方法的个数;where fnum i is the number of attributes in class i , fnum j is the number of attributes in class j , mnum i is the number of methods in class i , mnum j is the number of methods in class j , and fnum ij is the number of methods in class i and class j The number of the same attributes in class i and class j, mnum ij is the number of the same methods in class i and class j ; 步骤S4当中通过预定义的方法相似度评判因素计算相似度具体包括以下步骤:In step S4, calculating the similarity by the predefined method similarity evaluation factors specifically includes the following steps: 以方法mi和mj的所属类两者之间的相似度、方法被调用的次数、方法调用其他方法的次数、调用mi的方法集合mi.call和调用mj的方法集合mj.call中存在映射关系的方法对占比、mi调用的方法集合mi.becall和mj调用的方法集合mj.becall中存在映射关系的方法对占比、方法签名6个评判因素计算方法mi和mj的相似度:In terms of the similarity between the classes of methods m i and m j , the number of times the method is called, the number of times the method calls other methods, the method set m i.call that calls m i and the method set m j that calls m j The proportion of method pairs with a mapping relationship in .call, the method set called by m i m i .becall and the method set called by m j m j . The proportion of method pairs with a mapping relationship in .becall and the method signature are calculated by 6 evaluation factors Similarity of methods m i and m j : smij=0.15*p1ij+0.2*p2ij+0.2*p3ij+0.15*p4ij+0.15*p5ij+0.15*p6ijsm ij =0.15*p 1ij +0.2*p 2ij +0.2*p 3ij +0.15*p 4ij +0.15*p 5ij +0.15*p 6ij ; p1ij=scabp 1ij =sc ab ;
Figure FDA0003023504250000051
Figure FDA0003023504250000051
Figure FDA0003023504250000052
Figure FDA0003023504250000052
Figure FDA0003023504250000053
Figure FDA0003023504250000053
Figure FDA0003023504250000054
Figure FDA0003023504250000054
p6ij=0.8*sim1ij+0.2*sim2ijp 6ij =0.8*sim 1ij +0.2*sim 2ij ;
Figure FDA0003023504250000055
Figure FDA0003023504250000055
Figure FDA0003023504250000056
Figure FDA0003023504250000056
其中,becallmij为mi.becall和mj.becall中存在映射关系的方法对个数,becallnumij为mi.becall或mj.becall的元素个数,callmij为mi.call和mj.call中存在映射关系的方法对个数,callnumij为mi.call或mj.call的元素个数。Among them, becallm ij is the number of method pairs that have a mapping relationship in mi.becall and mj.becall, becallnum ij is the number of elements of mi.becall or mj.becall , and callm ij is mi.call and m The number of method pairs with mapping relationship in j.call, callnum ij is the number of elements of m i.call or m j.call .
2.根据权利要求1所述的建立不同版本程序类集合映射关系的方法,其特征在于:步骤S5具体包括:2. the method for establishing different version program class sets mapping relationship according to claim 1, is characterized in that: step S5 specifically comprises: 取具有最高相似度的方法对,建立方法的“一对一”映射,通过方法的映射关系逐步调整类的相似度,通过逐步迭代的方式更新类间的相似度,当最后一个方法确定完映射关系,类的相似度也最终确定,确定一个阈值,建立类的映射关系,最终得出类的“一对一”或“一对多”或“多对一”映射关系。Take the method pair with the highest similarity, establish a "one-to-one" mapping of methods, gradually adjust the similarity of the classes through the mapping relationship of the methods, and update the similarity between the classes in a step-by-step iterative manner. When the last method determines the mapping The relationship, the similarity of the classes is also finally determined, a threshold is determined, the mapping relationship of the classes is established, and the "one-to-one" or "one-to-many" or "many-to-one" mapping relationship of the classes is finally obtained. 3.根据权利要求1所述的建立不同版本程序类集合映射关系的方法,其特征在于:所述类相似度评判因素包括:类名、属性个数、方法个数、相似属性占比和相似方法占比;所述方法相似度评判因素包括:方法所属类两者之间的相似度、该方法被调用的频率、该方法调用其他方法的频率、调用这两个方法的方法集合中存在映射关系的方法对占比、这两个方法调用的方法集合中存在映射关系的方法对占比和方法签名。3. the method for establishing different version program class sets mapping relationship according to claim 1, is characterized in that: described class similarity evaluation factor comprises: class name, attribute number, method number, similar attribute ratio and similar The proportion of methods; the method similarity evaluation factors include: the similarity between the classes to which the method belongs, the frequency of the method being called, the frequency of the method calling other methods, and the existence of a mapping in the method set that calls these two methods The proportion of method pairs of the relationship, the proportion of method pairs with a mapping relationship in the method set called by these two methods, and the method signature. 4.据权利要求2所述的建立不同版本程序类集合映射关系的方法,其特征在于:步骤S5具体通过以下算法实现:4. the method for setting up different version program class sets mapping relationship according to claim 2 is characterized in that: step S5 is specifically realized by following algorithm: 输入新版本程序的方法;The method of entering the new version of the program; 输入旧版本程序的方法;The way to enter the old version of the program; 输入初步的类相似度矩阵simClass;Enter the preliminary class similarity matrix simClass; 输入方法相似度矩阵simMethod;Input method similarity matrix simMethod; 遍历方法相似度矩阵,直到新版本程序所有方法都建立映射关系:Traverse the method similarity matrix until all methods in the new version of the program have established mapping relationships: 在方法相似度矩阵寻找具有最高相似度的方法对,将方法对和相应的相似度存储在方法映射表中;Find the method pair with the highest similarity in the method similarity matrix, and store the method pair and the corresponding similarity in the method mapping table; 根据公式scij=(scij+1)/2更新方法对所属的两个类的相似度,从而更新类相似度矩阵;Update the similarity of the two classes to which the method belongs according to the formula sc ij =(sc ij +1)/2, thereby updating the class similarity matrix; 更新becallmij,将其加一;update becallm ij , increment it by one; 更新callmij,将其加一;update callm ij , increment it by one; 更新方法相似度矩阵;Update method similarity matrix; 更新类相似度矩阵;Update the class similarity matrix; 遍历类相似度矩阵,若两个类的相似度大于阈值,将这两个类和其对应的相似度存储在类映射表中;Traverse the class similarity matrix, if the similarity of the two classes is greater than the threshold, store the two classes and their corresponding similarity in the class mapping table; 输出方法映射表和类映射表。Output method mapping table and class mapping table.
CN201911138413.5A 2019-11-20 2019-11-20 Method for Establishing Mapping Relationship of Program Class Collections of Different Versions Active CN110908705B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911138413.5A CN110908705B (en) 2019-11-20 2019-11-20 Method for Establishing Mapping Relationship of Program Class Collections of Different Versions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911138413.5A CN110908705B (en) 2019-11-20 2019-11-20 Method for Establishing Mapping Relationship of Program Class Collections of Different Versions

Publications (2)

Publication Number Publication Date
CN110908705A CN110908705A (en) 2020-03-24
CN110908705B true CN110908705B (en) 2021-06-22

Family

ID=69816748

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911138413.5A Active CN110908705B (en) 2019-11-20 2019-11-20 Method for Establishing Mapping Relationship of Program Class Collections of Different Versions

Country Status (1)

Country Link
CN (1) CN110908705B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104778409A (en) * 2015-04-16 2015-07-15 电子科技大学 Method and device for detecting similarities of Android application software
CN104933360A (en) * 2015-05-21 2015-09-23 中国科学院信息工程研究所 Android platform counterfeit application detection method based on program dependency graph
CN105550540A (en) * 2014-10-31 2016-05-04 中国移动通信集团江苏有限公司 Detection method and device for homogenization application
CN109254764A (en) * 2018-09-28 2019-01-22 福州大学 The method of software architecture when the acquisition operation of curstomer-oriented end application program

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104808983B (en) * 2015-03-19 2018-08-07 深圳市创梦天地科技有限公司 A kind of method for pushing and server of application program
US10331548B2 (en) * 2016-08-05 2019-06-25 Dspace Digital Signal Processing And Control Engineering Gmbh Method and computer system for compiling and testing a control program
US10114624B1 (en) * 2017-10-12 2018-10-30 Devfactory Fz-Llc Blackbox matching engine
CN108256030B (en) * 2017-12-29 2020-10-23 北京理工大学 Ontology-based density adaptive concept semantic similarity calculation method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105550540A (en) * 2014-10-31 2016-05-04 中国移动通信集团江苏有限公司 Detection method and device for homogenization application
CN104778409A (en) * 2015-04-16 2015-07-15 电子科技大学 Method and device for detecting similarities of Android application software
CN104933360A (en) * 2015-05-21 2015-09-23 中国科学院信息工程研究所 Android platform counterfeit application detection method based on program dependency graph
CN109254764A (en) * 2018-09-28 2019-01-22 福州大学 The method of software architecture when the acquisition operation of curstomer-oriented end application program

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LogPruner: detect, analyze and prune logging calls;Xin ZHOU;《SCIENCE CHINA Information Sciences》;20180501;第1-3页 *
程序代码相似度检测技术的研究与实现;卫军超 等;《电脑知识与技术》;20170407;第39-40页 *

Also Published As

Publication number Publication date
CN110908705A (en) 2020-03-24

Similar Documents

Publication Publication Date Title
JP7419244B2 (en) Learning ETL rules by example
US20250028733A1 (en) Enhanced mechanisms for managing multidimensional data
US9305109B2 (en) Method and system of adapting a data model to a user interface component
US11693833B2 (en) Computer-implemented method for storing unlimited amount of data as a mind map in relational database systems
US7275024B2 (en) Automatic generation of a dimensional model for business analytics from an object model for online transaction processing
US9710529B2 (en) Data construction for extract, transform and load operations for a database
US20120095957A1 (en) Component Based Approach to Building Data Integration Tools
US8881127B2 (en) Systems and methods to automatically generate classes from API source code
US9740713B1 (en) Dynamic modeling of data in relational databases
KR102220246B1 (en) Data generation
US8122044B2 (en) Generation of business intelligence entities from a dimensional model
JP2004520635A (en) Object-oriented software application with application framework for oil company model assets
US8862637B2 (en) Generating data access operations based on a data model using a data services model
US20110153562A1 (en) Error prevention for data replication
WO2020259325A1 (en) Feature processing method applicable to machine learning, and device
WO2012130489A1 (en) Method, system, and computer program product for maintaining data consistency between two databases
CN102193802A (en) Method for converting models with model subsets of same base class structure
CN110908705B (en) Method for Establishing Mapping Relationship of Program Class Collections of Different Versions
US20070083543A1 (en) XML schema template builder
JP7250009B2 (en) How it is done by client-end programming tools
CN117539433A (en) Microservice design method based on model driven architecture
KirMani Dimensional Modeling Using Star Schema for Data Warehouse Creation
Fries A framework for transforming structured analysis and design artifacts to UML
US20220398228A1 (en) Implementing tenancy isolation for entities
Sokolov et al. Hybrid approach to building object-oriented programs with databases

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant