Unlock instant, AI-driven research and patent intelligence for your innovation.

A method for clone detection of java source code

A source code, java-like technology, applied in the computer field, can solve the problems of poor generality and accuracy of clone detection methods, and achieve the effects of low cost, improved efficiency, and efficient detection

Active Publication Date: 2021-07-27
STATE GRID SICHUAN ELECTRIC POWER CORP ELECTRIC POWER RES INST
View PDF6 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0006] The technical problem to be solved by the present invention is that the versatility and accuracy of various clone detection methods in the prior art are relatively poor, and the purpose is to provide a method for Java source code clone detection to solve the above problems

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • A method for clone detection of java source code
  • A method for clone detection of java source code
  • A method for clone detection of java source code

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0041] Such as figure 1 As shown, a method for cloning detection of Java source code of the present invention comprises the following steps: S1: extracting the class in the Java source code as the minimum extraction unit; S2: uniformly replacing the function name and the variable name in the Java class; S3: Compare the classes in the Java source code, and output the comparison result.

[0042] During the implementation of this embodiment, the class in the Java source code is extracted as the minimum extraction unit, and the function name and variable name in the Java class are uniformly replaced, so that when different codes are cloned and detected, even if the function name and variable name in the class are When the variable name is changed, the accurate comparison of the class can also be realized, and then the clone detection of the entire code through the class can effectively improve the accuracy of the clone detection. This method is aimed at the exact same reuse of the...

Embodiment 2

[0044] In this embodiment, on the basis of Embodiment 1, step S2 includes the following sub-steps: scan each Java class, and uniformly replace the terminator representing the variable name in the Java class with a literal value; define a tag type for extending or customizing field.

[0045] During the implementation of this embodiment, in order to shield the impact of the variable name in the java source program on the clone code detection, each java class is scanned, and the terminators [id], [number], [ stringlit] and other basic types are uniformly replaced by the literal x, and the comment content is uniformly replaced by [comment], and the custom [tokens] section is used to extend or customize token types.

Embodiment 3

[0047] In this embodiment, on the basis of Embodiment 1, step S1 includes the following sub-steps: define a root non-terminator of a class, and use the root non-terminal as the root node to establish a parse tree; the parent nodes in the parse tree are all composed of The parent node is composed of a plurality of sorted child nodes; the parent nodes of the parsing tree are all non-terminators; the leaf nodes of the parsing tree are all terminators; the root non-terminals are represented as all leaf nodes the sequence of.

[0048] During the implementation of this embodiment, in order to further detect the java source program code clones that change, increase or delete program statements, but most of the text content of the code is the same, the present invention parses the class file and generates a parsing tree, according to the above method It is equivalent to defining each non-terminal from top to bottom, until each non-terminal is expressed as a series of terminators. In ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a method for cloning detection of Java source codes, comprising the following steps: S1: extracting classes in Java source codes as the minimum extraction unit; S2: uniformly replacing function names and variable names in Java classes; S3 : Compare the classes in the Java source code and output the comparison result. The present invention can not only efficiently detect the identical reuse of the entire code file or the code segment, but also simply clone the identical code except for spaces and comments. At the same time, it further detects the clones of java source program codes that change, increase or delete program statements, but the text content of the codes is mostly the same, and outputs accurate results.

Description

technical field [0001] The invention relates to the technical field of computers, in particular to a method for cloning detection of Java source codes. Background technique [0002] There is a clone relationship between two code fragments if and only if they are similar sequences. Clone pairs and clone classes can be defined according to the clone relationship: a pair of code fragments that satisfy the clone relationship is called a clone pair. The clone class is a maximum collection composed of clone pairs, and there are code fragments with different degrees of cloning in this collection. From low to high, the degree of cloning is divided into: clones of exactly the same code, clones of code that are identical except for comments, layouts, and variable names, and codes that have changed, added, or deleted program statements, but the text content of the code is similar Code cloning. [0003] Code cloning is common in software systems. Even the industry-recognized high-qu...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Patents(China)
IPC IPC(8): G06F11/36G06F21/12
CPCG06F11/3604G06F21/125
Inventor 张凌浩桂盛霖常晓青刘元生梁晖辉王胜唐超王海张颉甘炜
Owner STATE GRID SICHUAN ELECTRIC POWER CORP ELECTRIC POWER RES INST