Abstract:To address the problem of excessive randomness introduced by the mechanical exchange of gene fragments in traditional crossover operators, which leads to the generation of invalid refactoring operations, this paper proposed a refactoring recommendation method called RefCross based on an adaptive crossover operator. Firstly, the submitted Java projects were parsed using source code analysis tools to construct a code structure model to extract code metrics. Then the fitness function was designed and the fitness value was calculated based on the extracted code metrics to guide the optimization direction of the crossover operator. Finally, the parent classification mechanism based on feature matching was constructed, and the crossover strategy was formulated. By combining with common gene retention, adaptive selection of differential genes, and the elite gene reinforcement strategy, the offspring refactoring sequences that balanced high-quality feature inheritance and diversity in the solution space was generated, thereby reducing the probability of generating ineffective refactoring operations. The results show that RefCross outperforms existing methods in precision, recall, and F1 score metrics on six open-source projects, achieving an average F1 score of 77.82%, representing a baseline improvement of 9.10 percentage points. This method effectively enhances the effectiveness and accuracy of refactoring recommendations, providing strong support for automated refactoring decisions.