一句话:提出 Neurex,基于 CodeBERT 多任务微调,为 Java 片段推荐是否需 try-catch、try 块语句与捕获异常类型。
开发者论坛的代码片段常缺少异常处理细节,而适配代码库时需记住哪些 API 会抛异常、应处理哪些异常。本文提出 Neurex,一个从完整代码学习的异常处理推荐器:给定 Java 代码片段,推荐是否需 try-catch、哪些语句应放入 try 块,以及 catch 应捕获哪些异常类型。受 NLP 序列分块启发,作者用多任务模型微调 CodeBERT 联合完成三项任务。该模型可学习周围上下文,更好捕捉 API 元素间依赖及语句与异常类型的关系。摘要未报告具体实验指标。
With practical code reuse, the code fragments from developers' forums often migrate to applications. Owing to the incomplete nature of such fragments, they often lack the details on exception handling. The adaptation for exception handling to the codebase is not trivial as developers must learn and memorize what API methods could cause exceptions and what exceptions need to be handled. We propose Neurex, an exception handling recommender that learns from complete code, and accepts a given Java code snippet and recommends 1) if a try-catch block is needed, 2) what statements need to be placed in a try block, and 3) what exception types need to be caught in the catch clause. Inspired by the sequence chunking techniques in natural language processing, we design Neurex via a multi-tasking model with the fine-tuning of the large language model CodeBERT for these three exception handling recommendation tasks. Via the large language model, Neurex can learn the surrounding context, leading to better learning the dependencies among the API elements, and the relations between the statements and the corresponding exception types needed to be handled.
@inproceedings{paperbot11426,
title = {Programming Assistant for Exception Handling with CodeBERT},
author = {Yuchen Cai and Aashish Yadavally and Abhishek Mishra and Genesis Montejo and Tien Nguyen},
booktitle = {ICSE},
year = {2024},
doi = {10.1145/3597503.3639188}
}