| With the rapid development of global technology,computer software has gradually become a necessary tool for the construction of information-based society,so computer software is bound to become a future global development trend.However,there are a large number of defects in the development and use of software,repairing defects has become one of the most important aspects of software development.Therefore,automatic software defect repair technology has emerged as a hot issue for research in the field of software engineering.Automatic defect repair technology means that when a program in software is faulty,it can be repaired quickly and accurately to reduce debugging costs and improve software quality.In recent years,search-based repair methods have been popular among researchers.Such methods mainly use heuristic search algorithms such as genetic programming to search for the correct patch in the potential space and test it to verify the correctness of the patch.In this thesis,we propose two methods for automatic repair of defects based on genetic programming optimization and develop a system tool to integrate the two methods.The details of the research are as follows:(1)To address the problem that a single objective(the number verified by test cases)to verify the selection of child patches,without selecting more superior children by other constraints,affects the patch generation efficiency.We propose MGPRepair,an automatic software repair technology based on multi-objective genetic programming.Firstly,the method uses a strategy of lightweight contextual analysis to find suitable repair material.Secondly,the replacement and insertion statements in the repair material are decoupled and patches in the search space are encoded using a lower-granularity patch representation.Then,automatic software defect repair is considered as a multi-objective search problem and a simpler repair patch is found using the NSGA-II multi-objective optimization algorithm.Finally,test case filtering techniques are used to speed up the patch validation process.MGPRepair was experimentally evaluated on 395 real Java software defects from the defect dataset Defects4 J.The experimental evaluation results show that MGPRepair can generate patches that pass test cases for 51 defects,35 of which are equivalent to manually generated patches.The repair efficiency and success rate outperform excellent automatic software defect repair methods such as j Gen Prog,RSRepair,ARJA,Nopol,Capgen and Sequence R.(2)To address the problem that the low quality of initialized populations leads to slow convergence of the search algorithm,which seriously affects the efficiency of patch generation.We propose MTGPRepair,an automatic software repair technology based on Machine Translation and Genetic Programming.Firstly,use the fault localization method Ochiai to locate the defect location and generate a defect report.Secondly,the manual repair template is context-matched with the defect location in the defect report to generate a partial initial population.Then,a bidirectional recurrent neural network model in neural machine translation is used to learn the relationship between the defect code and the repair code,and the model is used to generate high-quality initial populations for the defect locations.Finally,a genetic programming approach is used to search for correct patches and test case filtering techniques are employed to speed up the patch validation process.MGPRepair was experimentally evaluated on 395 real Java software defects from the defect dataset Defects4 J.The experimental results show that MTGPRepair can generate patches that pass test cases for 58 defects,of which 39 defect patches are equivalent to manually generated patches.MTGPRepair has better repair results compared with excellent automatic software defect repair methods such as PAR,j Genprog,ACS,RSRepair,ARJA,Nopol,Capgen and Sequence R.(3)An automatic repair tool is designed and implemented for the two automatic defect repair methods proposed in this thesis.The repairing tool can be customized to select the defect location method to be used and the two repairing methods in this thesis according to the requirements.Test case filtering,patch overfit detection,and other features are optional options that are highly user-friendly and customizable.Following the prompts of the repairing tool is valuable in practical applications. |