Modern software systems rely on a multitude of third-party dependencies. This large-scale code reuse reduces development costs and time, and it poses new challenges with respect to maintenance and security. Techniques such as tree shaking or shading can remove dependencies that are completely unused by a project, which partly address these challenges. Yet, the remaining dependencies are likely to be used only partially, leaving room for further reduction of third-party code. In this paper, we propose a novel technique to specialize dependencies of Java projects, based on their actual usage. For each dependency, we systematically identify the subset of its functionalities that is necessary to build the project, and remove the rest. Each specialized dependency is repackaged. Then, we generate specialized dependency trees where the original dependencies are replaced by the specialized versions and we rebuild the project. We implement our technique in a tool called DepTrim, which we evaluate with 30 notable open-source Java projects. DepTrim specializes a total of 343 (86.6%) dependencies across these projects, and successfully rebuilds each project with a specialized dependency tree. Moreover, through this specialization, DepTrim removes a total of 60,962 (47.0%) classes from the dependencies, reducing the ratio of dependency classes to project classes from 8.7x in the original projects to 4.4x after specialization. These results indicate the relevance of dependency specialization to significantly reduce the share of third-party code in Java projects.
翻译:现代软件系统依赖第三方的多种依赖性。 这种大规模代码再利用会降低开发成本和时间,并给维护和安全带来新的挑战。 树的摇晃或阴影等技术可以消除一个项目完全未使用的、部分应对这些挑战的项目完全未使用的依赖性。 然而,剩下的依赖性可能只是部分地使用,为进一步减少第三方代码留有余地。 在本文件中,我们根据Java项目的实际使用情况,提出一种新颖的技术,专门确定Java项目依赖性。对于每个依赖性,我们系统地确定建设项目和清除其余部分所需的功能。每个专门依赖性都重新包装。然后,我们在最初依赖性被专门版本取代的地方产生专门的依赖性树,并重建项目。 我们用一个名为DepTrim(我们用30个显著的开放性 Java项目来评估)的工具实施我们的技术。 DepTrim(我们根据这些项目的实际使用情况,提出了总共343 (86.6%) 依赖性项目,并成功地重建每个项目中具有专门性依赖性相关性的部分。 此外,通过这一专业化的8级,DeprimTrimital 将项目从60级从原来的专业化项目从最初的分类减少到整个。