首页|异常信息敏感的框架API生命周期模型构造

异常信息敏感的框架API生命周期模型构造

扫码查看
大型软件系统的实现依赖于底层框架或第三方库,但这些复杂的框架/库代码在演化升级时往往独立于其调用者,为上层软件的质量保障带来挑战.例如,框架/库代码演化时新增和删除API、更改API的代码语义等行为会导致框架/库代码的不同版本之间不兼容,进而在上层应用开发者更新版本时,影响应用代码的正确性.为应对这一问题,需精准提取框架/库代码API的演化过程,形成演化报告,协助上层应用开发者选择兼容的版本或快速进行代码适配.其中,框架/库代码API的演化过程分析对应着框架API生命周期模型构造.现有工作中的API生命周期模型主要关注API的存在性变动,而未考虑特定代码语义变更对开发者的影响,特别是异常相关代码带来的语义变更,给上层软件系统带来隐患.为此,本文采用面向Java字节码的静态分析方法,识别框架API中的异常抛出行为并为其生成异常摘要报告,通过多轮流式匹配策略获取异常信息的变更情况,最终为框架/库代码构造异常信息敏感的API生命周期模型.该方法:(1)通过控制依赖语句切片提取异常抛出语句的关键触发条件,采用参数推断策略将局部变量的约束条件转换为仅与外部输入参数相关的异常前断言,并基于自底向上的摘要传递实现跨过程异常摘要提取;(2)通过关键信息精准匹配和自适应模糊匹配策略,分析异常摘要信息的新增、删除和修改情况,最终得到异常敏感的API生命周期模型(共涉及七种API变更形式).基于该方法,实现了基于Java字节码分析的API生命周期提取工具JavaExP.与现有最新方法相比,JavaExP的异常摘要信息提取准确性(F1值)提高了 67%,分析用时减少了 87%.对真实项目的API生命周期演化分析表明,与异常不敏感的API生命周期模型相比,采用异常敏感的模型时,API发生变动的比例提高了 18%.在75,433个被分析的API中,约有20%API的异常抛出行为至少发生过一次改变,这些API共涉及超过七千多处独立的异常变更.在多个项目上的分析结果表明,异常敏感的模型构造能够更加精准地描述API的演化过程.
Exception-aware Lifecycle-Model Construction for Framework APIs
The implementation of large-scale software systems usually depends on low-level frameworks,or third-party libraries.However,the evolution of these frameworks or libraries is independent of the upper-level applications,which brings challenges in upper-level code quality assurance.For instance,changes in framework/library code,such as adding or removing APIs and altering API semantics,may result in inconsistencies among different versions of the frame-work/library code.These inconsistencies can impact the quality of higher-level apps when devel-opers update frameworks/libraries.To address this issue,analyzing the evolution process of framework/library code APIs is essential.This analysis helps upper-level app developers swiftly choose compatible versions or adjust their code.In this context,analyzing the evolution process corresponds to constructing a framework API lifecycle model.Nowadays,existing works propose the API existence-changing model for defect detection,while not considering the influence of se-mantic changes in APIs,especially exception-related code evolution.To fill this gap,this paper adopts static analysis techniques to extract exception summary information in the framework API code,proposes a multi-step matching strategy to obtain the changing process of exceptions,and finally generates exception-aware API lifecycle models for the given framework/library project.Our approach:(1)adopts control-dependency slicing analysis to extract the conditions of the ex-ception-thrown statements;uses a parameter tracing strategy to transform exception-throwing conditions into external-variable-related preconditions;and performs inter-procedure precondition construction by a bottom-up summary-based analysis.(2)proposes the exact-matching and adap-tive-matching strategies to analyze the framework/library code changes including additions,dele-tions and modifications of APIs;generates exception-aware API lifecycle models which cover sev-en API changing types.With this approach,the API lifecycle extraction tool,JavaExP,is imple-mented,which is based on Java bytecode analysis.Compared to the state-of-the-art tool,the F1 score of exception summary information extracted by JavaExP has increased by 67%,with a re-duction in processing time by 87%.The evaluation of real-world projects shows that,compared to the exception-unaware API lifecycle modeling,JavaExP can identify 18%times more API changes.Among the 75,433 APIs under analysis,20%of APIs have changed their exception-throwing behavior at least once after API introduction.These APIs involve a total of more than 7K independent exception changes.The overall results show that the exception-aware lifecycle modeling can describe the evolution process of APIs more accurately.

static analysisprogram evolutionJava exception summaryAPI lifecycle

燕季薇、黄进豪、杨恒钦、严俊

展开 >

中国科学院软件研究所软件工程技术研究开发中心 北京 100190

北京工业大学信息学部 北京 100124

国科大杭州高等研究院 杭州 310024

中国科学院软件研究所基础软件与系统重点实验室 北京 100190

中国科学院软件研究所计算机科学国家重点实验室 北京 100190

展开 >

静态分析 代码演化 Java异常摘要 API生命周期

国家自然科学基金青年科学基金国家自然科学基金重点项目中国科学院软件研究所创新基金重大重点项目

6210240562132020ISCAS-ZD-202302

2024

计算机学报
中国计算机学会 中国科学院计算技术研究所

计算机学报

CSTPCD北大核心
影响因子:3.18
ISSN:0254-4164
年,卷(期):2024.47(9)
  • 3