Page 121 - 《软件学报》2025年第7期
P. 121

3042                                                       软件学报  2025  年第  36  卷第  7  期


                 study  aims  to  address  the  gaps  in  the  analysis  of  dependency  management  issues  found  in  existing  research  and  technical  literature  by
                 introducing  the  concept  of  “dependency  smell”,  to  build  a  unified  model  for  these  challenges.  This  study  conducts  a  comprehensive
                 empirical  study  on  dependency  management  issues,  covering  all  categories  of  Maven  and  Gradle  related  problems.  This  study  analyzes
                 diverse  dependency  management  issues  gathered  from  open-source  communities  (e.g.,  GitHub),  official  documentation  (e.g.,  Maven
                 manual),  as  well  as  various  surveys  and  technical  papers.  Finally,  13  types  of  dependency  smell,  as  well  as  their  triggering  roots  and
                 impact  characteristics,  are  summarized.  Based  on  the  findings  of  this  empirical  study,  a  unified  detection  algorithm  for  dependency  smells
                 in Java projects is designed, and a special detection tool JDepAna suitable for Maven and Gradle build tools is implemented. Experimental
                 results  demonstrate  that  for  known  dependency  smells,  JDepAna  achieves  a  detection  recall  rate  of  95.9%.  For  hundreds  of  new  Java
                 projects,  JDepAna  detects  30 689  instances  of  dependency  smells.  360  instances  are  selected,  and  the  true  positive  rate  of  manual
                 verification  reaches  96.1%.  Additionally,  this  study  reports  48  instances  to  developers,  with  42  instances  promptly  confirmed  and  21
                 promptly  fixed,  thereby  validating  the  efficacy  and  practicality  of  the  proposed  Java  dependency  smell  detection  algorithm  and  tool  in
                 facilitating quality assurance for Java projects.
                 Key words:  dependency management; software ecosystem; quality assurance; empirical study; static analysis
                    Java 语言因为丰富的依赖库而广泛被使用于应用开发                [1] , 开发者可以通过复用依赖库来提高开发效率和软件
                                                                                                  [3]
                 质量  [2] . 为了管理应用开发过程中繁复且多变的依赖库, Java 提供了便捷的构建工具                  (如  Maven  和  Gradle) , 开发
                 者只需在对应配置文件中进行配置, 构建工具就会自动化地获取依赖库并进行集中管理.
                    然而随着依赖库的持续演进与规模扩张, Java 项目的依赖管理任务日益复杂化, 其中隐含的问题可能在非预
                 期时刻被触发, 进而造成严重危害          [4] . 鉴于此, 本文引入了依赖异味      (dependency smell) 的概念, 指的是依赖配置文
                 件或代码中潜在的对软件项目或生态系统演化产生负面影响的不良依赖管理模式或特征. 这些模式或特征可能导
                 致对软件的理解、维护或扩展存在挑战, 从而影响软件的整体质量和稳定性. 依赖异味作为隐藏在依赖管理深处
                 的隐患, 虽可能不直接导致程序缺陷           (Bug), 但增加了引入缺陷的风险, 最终可能在特定情境下会被触发进而影响
                 项目的构建和运行, 导致诸如构建失效、运行崩溃或语义冲突等一系列问题. 以                        GitHub 中的问题报告    (Issue) #EL-
                    [5]
                                   [6]
                 1849 为例, 项目  Jersey 在代码中使用了依赖库        eclipse:asm:9.4.0, 但却未在配置文件中声明. 与此同时      Jersey  的
                 另一依赖库    eclipse:moxy:4.0.0  明确声明了对  asm:9.4.0  的依赖关系, 这起初使得  Jersey  能够经由  moxy:4.0.0  间接
                 获得  asm:9.4.0  并维持正常运作. 然而    moxy:4.0.1  移除了对  asm:9.4.0  的依赖, 随着  Jersey  将  moxy:4.0.0  升级为
                 moxy:4.0.1, 其构建过程中无法找到     asm:9.4.0, 最终导致构建时出现     ExceptionInInitializerError 异常.
                    值得注意的是, Java 项目依赖管理中的类似问题已经引起了研究者的广泛关注, 例如对                         Maven  项目中依赖冲
                 突和依赖冗余问题的分析         [7−11] . 然而, 目前针对  Java 中依赖异味的研究仍存在空缺. 首先, 目前研究大多关注依赖
                 管理已对项目造成的危害, 但未充分考虑依赖管理中潜在的问题. 此外, 目前的研究主要关注于使用                               Maven  进行
                 依赖管理的    Java 项目. 但在传统的构建工具       Maven  之外, 新兴的构建工具     Gradle 同样被广泛使用. Gradle 提供了
                 更多的灵活性和定制化选项, 使开发者能够更精细地控制项目的依赖关系, 但也增加了研究的难度                                [12] . 在  Java 语
                 言之外, Cao  等人  [13] 和  Jafari 等人  [14] 分别对  Python  和  JavaScript 中的依赖异味进行了调研, 发现了依赖异味在这
                 两种语言中的普遍性. 虽然由于语言特性和构建工具配置方式的显著差异, Python                       和  JavaScript 中的异味并不直
                 接适用于   Java, 但也启发我们    Java 依赖异味研究存在对应空缺.
                    针对现有工作对      Java 语言依赖管理中潜藏问题分析不足的缺陷, 我们综合官方文档                   [15,16] 、学术论文  [7−14,17−29]
                 以及开源社区     GitHub  [30] 中的问题报告开展实证研究, 最终发现       Maven  和  Gradle 两大构建工具中的    13  类依赖异
                 味. 我们详细分析了这些依赖异味对应的特征和具体的实例, 并探讨它们的潜在危害及触发场景. 基于实证研究结
                 果, 我们设计了针对      Maven  和  Gradle 项目的依赖模型以及检测上述依赖异味的统一检测算法, 并实现了适配于
                 Maven  和  Gradle 的专项检测工具  JDepAna.
                    为了评估    JDepAna 的检测效果, 我们收集了包含        147  个已知依赖异味实例的基准集. JDepAna 在此基准集上
                 的表现卓越, 达到了      95.9%  的召回率和  96.1%  的精确率. 此外, 我们在流行的       73  个  Maven  项目和  51  个  Gradle 项
                 目中进一步验证, JDepAna 在这些实际项目上的精确率同样维持在                  96.1%  的高水平. 我们据此向开发者报告了         48
                 例检测出的依赖异味实例, 其中          42  例  (87.5%) 得到了确认, 21  例  (43.8%) 已被快速修复. 这一系列的实验证明了
   116   117   118   119   120   121   122   123   124   125   126