基于大语言模型的Java新特性测试程序生成
作者:
作者单位:

作者简介:

通讯作者:

中图分类号:

TP311

基金项目:

国家重点研发计划(2024YFB4506300); 国家自然科学基金(62472310, 62322208, 62232001, 12411530122)


Java New Feature Test Program Generation Based on Large Language Models
Author:
Affiliation:

Fund Project:

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 资源附件
  • |
  • 文章评论
    摘要:

    Java编程语言自诞生以来, 就始终处于不断发展和演变的过程中. 随着新语言特性及编程范式的不断涌现, Java的表达能力和执行效率在不断提升, 推动了整个软件生态的进步. 为了确保Java生态的安全性和稳定性, 研究人员设计了多种针对Java编译器及虚拟机的测试程序生成方法, 以检测潜在的缺陷. 然而, 现有工作主要针对成熟的语法设计测试程序生成方法或变异策略, 难以对语言新特性进行有效的测试. 为此, 提出一种基于大语言模型的Java新特性测试程序生成方法LumiX. 首先, LumiX利用大模型对使用自然语言描述的新语言特性进行总结, 概括得到新特性的使用描述; 随后, LumiX以历史揭错测试程序作为种子程序, 利用程序分析工具提取种子程序中可复用的程序元素, 结合新特性的使用描述, 利用大模型生成针对新特性的代码片段. 新生成的代码片段将被插入至种子程序中, 生成能够覆盖新特性的测试程序. 最后, LumiX设计了双层的差分测试方法, 分别利用不同的Java编译器(javac和ECJ)及Java虚拟机(HotSpot和OpenJ9)对新生成的测试程序进行编译和执行, 通过对比不同编译器和虚拟机的执行结果来检测潜在的缺陷. 实验结果表明, LumiX能够有效生成覆盖Java语言新特性的测试程序, 并提升现有工具对Java语言新特性的测试能力. 同时, 将LumiX应用于最新发布的Java编译器以及虚拟机的测试中, 累计发现16个未知缺陷, 其中12个已被开发人员确认或修复.

    Abstract:

    Since its inception, the Java programming language has been in a process of constant development and evolution. As new language features and programming paradigms continuously emerge, Java’s expressiveness and execution efficiency are steadily improving, driving progress in the whole software ecosystem. To ensure the security and stability of the Java ecosystem, researchers have designed multiple test program generation methods for Java compilers and virtual machines to detect potential defects. However, the existing research primarily focuses on designing test program generation methods or mutation strategies for mature Java syntax, making it challenging to effectively test new language features. To this end, this study proposes LumiX, a test program generation method for Java’s new features based on large language models (LLMs). First, LumiX adopts LLMs to summarize new language features using natural language descriptions and obtains the usage descriptions of the new features. Then, it employs historically bug-revealing test programs as seed programs and applies program analysis tools to extract reusable program elements from the seed programs. By combining the usage descriptions of new features, LLMs are employed to generate code snippets that incorporate the new features. The newly generated code snippets are then inserted into the seed programs to generate test programs that can cover the new features. Finally, LumiX designs a dual-layer differential testing method, which utilizes different Java compilers (javac and ECJ) and virtual machines (HotSpot and OpenJ9) to compile and execute the newly generated test programs, with potential defects detected by comparing the execution results of different compilers and virtual machines. Experimental results show that LumiX can effectively generate test programs that cover Java’s new language features and enhance the testing capabilities of existing tools for Java’s new language features. Additionally, this study applies LumiX to the latest released Java compilers and virtual machines, and a total of 16 unknown defects have been discovered, 12 of which have been confirmed or fixed by developers.

    参考文献
    相似文献
    引证文献
引用本文

赵英全,张博凯,王赞,郭以勒,陈佳丽,陈翔,陈俊洁.基于大语言模型的Java新特性测试程序生成.软件学报,2026,37(7):2694-2718

复制
相关视频

分享
文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2025-09-08
  • 最后修改日期:2025-10-20
  • 录用日期:
  • 在线发布日期: 2025-12-26
  • 出版日期: 2026-07-06
文章二维码
您是第位访问者
版权所有:中国科学院软件研究所 京ICP备05046678号-3
地址:北京市海淀区中关村南四街4号,邮政编码:100190
电话:010-62562563 传真:010-62562533 Email:jos@iscas.ac.cn
技术支持:北京勤云科技发展有限公司

京公网安备 11040202500063号