Debloating Software Through Enhanced Static Analysis and Constraint Rules
Xiaohu Song, Hai Bo Yu, Ying Wang, Zhiliang Zhu · Software Practice and Experience · 2025
ABSTRACT Introduction Java applications often bloat, consuming more resources than necessary. Existing bytecode debloating techniques have several limitations, such as compromised correctness caused by incomplete code collection, which leads to false positives. The debloating process is resource‐intensive because it relies significantly on the test coverage to identify unnecessary code. This method is particularly problematic for large‐enterprise applications, where executing a single test case can take hours or days. In addition, most available debloating tools are standalone utilities that require manual configuration to be integrated with the project‐building process. Methods In this study, we introduce an automated approach known as Trimming. Trimming achieves three main improvements: (1) it collects the necessary code using enhanced static analysis, improves the modeling of reflective calls, and infers instantiation objects. It also uses constraint rules to identify and process reference codes that contribute to bloating but cannot be removed without causing errors. (2) It is not based on test coverage. (3) It allows for direct debloating from the project build by implementing a Maven plugin that is configured within the POM.xml file of the bloated project. Results Our evaluation results show that when Java reflection analysis or constraint rules in TRIMMING were disabled, the effectiveness of debloating analysis dropped to 88.25% with a 95% confidence interval (CI) of [85.3%, 91.2%], and 35.0% with a 95% CI of [30.5%, 39.5%], respectively. Moreover, inferring instantiation objects reduced the program size by 4.9%. Trimming achieved a bytecode reduction rate of 24.1%, with all the debloated projects successfully compiling and passing test suites.