Retrofitting Code Using LLMs to Support Exceptional Behavior
- ID: 984d7778
- 原文链接: https://arxiv.org/abs/2609.10397
- PDF: https://arxiv.org/pdf/2609.10397v1
- 作者: Linghan Zhong, Jiyang Zhang, Jayanth Srinivasa, Junyi Jessy Li, Milos Gligoric
- 日期: 2026-09-09
- 更新: 2026-09-09
- 分类: cs.SE, cs.CL
- 来源类型: paper
- 标签: code-generation, exception-handling, test-driven, context-engineering, field-note
- 质量评分: 4/5
- 抓取时间: 2026-09-11T12:23:09+00:00
中文导读
异常相关代码(ERC:throw 语句守护 throw 的 if 条件try/catch)是软件系统的基本组件,但在大代码库里手写非常枯燥论文提出新任务:给存量代码"加装"ERC给定无 ERC 代码和异常行为测试(EBT,如"传 null 应抛 InvalidArgumentException"),自动生成缺失 ERC 使测试通过 EXCODER 用 context engineering 解决:静态+动态程序分析提取上下文喂给 LLM 基准从 GitHub Java 仓库构建,系统性移除 75 个项目 304 个方法中的 ERC 配 Qwen 2.5 Coder 32b:开发者写的测试套件上 pass@1 85.92%(超基线 12.56pp)pass@5 86.18%pass@10 86.51%;人工检查也揭示了局限与后续方向这是第一个按 TDD 思路补 ERC 的自动化方案
为什么值得关注
新任务:给存量代码按 EBT 测试"补装"异常处理;EXCODER 用静态+动态分析做 context engineering,Qwen 2.5 Coder 32b 上 pass@1 85.92%(+12.56pp),TDD 式补 ERC 的第一个自动化方案
条目锚定 arXiv 2609.10397(2026-09-09 提交,分类 cs.SE, cs.CL),摘要自述贡献为上述机制与结论;详细信息以论文原文为准。
关键信息
- 论文标题: Retrofitting Code Using LLMs to Support Exceptional Behavior
- 作者: Linghan Zhong, Jiyang Zhang, Jayanth Srinivasa, Junyi Jessy Li, Milos Gligoric
- arXiv: https://arxiv.org/abs/2609.10397
- 发布时间: 2026-09-09
- arXiv 分类: cs.SE, cs.CL
- 关联标签: code-generation, exception-handling, test-driven, context-engineering, field-note
English Abstract
Exception Related Code (ERC), which includes throw statements, conditions (if statements) that guard those throw statements, and try/catch blocks, is an essential component of software systems, allowing developers to detect and handle exceptional states that deviate from the expected program behavior. However, manually writing ERC across large codebases is tedious. We propose a novel task: retrofitting existing code with ERC. Namely, given code (without ERC) and Exceptional Behavior Tests (EBTs) (e.g., check if method throws InvalidArgumentException if null is given as the value to the argument) we aim to automatically generate missing ERC, such that the given tests pass. We design and implement Exception Coder (EXCODER) that performs context engineering to help Large Language Models (LLMs) tackle this task. EXCODER integrates static and dynamic program analysis with LLMs by providing the extracted contextual information to the LLMs. To evaluate EXCODER, we build a benchmark constructed from GitHub Java repositories, where we systematically remove ERC in 304 methods from 75 projects. Our results demonstrate that EXCODER provides an effective, though imperfect, solution to this problem in automated code generation, offering developers the first way to implement ERC following test-driven development. When combined with Qwen 2.5 Coder 32b, EXCODER achieves pass@1, 5, and 10 rates of 85.92% (12.56 percentage points over baseline), 86.18% (12.82 p.p. over baseline), and 86.51% (13.15 p.p. over baseline), respectively, on developer-written test suites. Our manual inspection of the generated code further reveals limitations of EXCODER, pointing to directions for future work.
English Summary
The paper proposes a novel task, retrofitting existing code with Exception Related Code (ERC): given code without ERC and Exceptional Behavior Tests (EBTs), automatically generate the missing ERC so the tests pass. EXCODER performs context engineering for LLMs, integrating static and dynamic program analysis by feeding extracted contextual information to the models. A benchmark built from GitHub Java repositories systematically removes ERC in 304 methods across 75 projects. Combined with Qwen 2.5 Coder 32b, EXCODER achieves pass@1/5/10 of 85.92% (+12.56pp over baseline), 86.18%, and 86.51% on developer-written test suites, offering the first way to implement ERC following test-driven development.
Obsidian Notes
- 内容由
opencli arxiv paper拉取 arXiv 元数据与摘要生成。 - 中文导读与价值判断均锚定在条目已有摘要、论文摘要、作者、日期与分类信息上;未补充论文摘要之外的实验细节。