/jdebloat

We designed, implemented, and evaluated three static debloating and delayering functionalities for Java: (1) JShrink: statically remove the body of uninvoked methods through call graph analysis and dynamic profiling, (2)JReduce: reduce unused classes efficiently by taking into dependency based connected component structure for Delta Debugging and (3) JInline: statically inline the body of called methods aggressively

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Java Bytecode Debloating and Delayering

This project is led by Professor Miryung Kim (PI), Jens Palsberg, and Harry Xu (co-PIs) at UCLA.

For more information on Java Bytecode Debloating project at UCLA, please visit http://debloating.cs.ucla.edu.

Motivation

Modern software is bloated. Demand for new functionality has led developers to include more and more features, many of which become unneeded or unused as software evolves. This phenomenon, known as software bloat, results in software consuming more resources than it otherwise needs to. Various debloating techniques have been proposed since the late 1990s. However, many of these techniques are built upon pure static analysis and have yet to be extended and evaluated in the context of modern Java applications where dynamic language features are prevalent. To this end, we developed an end-to-end bytecode debloating framework called JShrink. It augments traditional static reachability analysis with dynamic profiling and type dependency analysis and renovates existing bytecode transformations to account for new language features in modern Java. This work is motivated and sponsored by Office of Naval Research Total Protection Cyber Platform program.

Components

JDebloat integrates three static debloating and delayering functionalities: (1) JReduce: statically reduce unused classes efficiently by taking into dependency based connected component structure while applying Delta Debugging for the purpose of code minimization, (2) JShrink: statically remove the body of uninvoked methods through call graph analysis, (3) JInline: statically inline the body of called methods aggressively, which are currently inlined by JVM’s runtime optimization.

  1. JShrink (https://github.com/jdebloat/jshrink)

  2. JInline (https://github.com/jdebloat/jinline)

  3. JReduce (https://github.com/jdebloat/jreduce)

More information on this debloating project can be found here.

There are two options to execute this tool explained below.

People

This JDebloat project is led by Professor Miryung Kim in the Computer Science department at UCLA.

JShrink's main contributors are Professor Miryung Kim, Tianyi Zhang, Bobby Bruce, and Jaspreet Arora. Its web user interface, WebJShrink was developed by Konner Macias and Mihir Mathur.

JReduce's main contributors are Professor Jens Palsberg and Christian Kalhauge.

JInline's main contributors are Harry Xu and Jon Eyolfson and Christian Navasca

In addition, integration of three tools into JDebloat and its end-to-end evaluation effort is supported by Yifan Qiao, Jiyuan Wang, Haoran Ma, Usama Hameed, and Akshay Uttere.

Video

JShrink at FSE 2020

WebJShrink at FSE 2020

How to Install and Run

Using a VM

You can find both tools and subject programs in the VM image. You are required to install the following software, described below.

  • VirtualBox 5.2.22
  • vagrant 2.2.2

To setup and enter the VM, please tun the following:

vagrant up
vagrant ssh
cd /vagrant

Using a Linux Machine locally

You are required to install the following software, described below.

To setup, please set the JAVA_HOME environment variable to point to the Java installation home folder (Instructions here - https://docs.oracle.com/cd/E19182-01/821-0917/inst_jdk_javahome_t/index.html)

Setup

Some of the tools require setup. You can run the setup for all the projects with the following command:

./jdebloat.py setup

Running the tools

The tool can be executed through the interface provided by the jdebloat.py script.

The usage for the script can be listed with the help([-h]) option as follows.

./jdebloat.py -h

usage: jdebloat.py [-h] {clean,setup,run}

positional arguments:
  {clean,setup,run}

optional arguments:
  -h, --help         show this help message and exit

The three positional arguments available for each tool in the package:

  1. Setup - to perform setup and compilation for the tool
  2. Run - to execute the tool with the benchmark projects
  3. Clean - to perform cleanup for the tool

Examples:

Run all 3 debloat tools in sequence.

./jdebloat.py setup
./jdebloat.py run
./jdebloat.py clean

To run the JReduce tool, run:

./jdebloat.py setup jreduce
./jdebloat.py run jreduce

To run the JShrink tool, run:

./jdebloat.py setup jshrink
./jdebloat.py run jshrink

To run the JInline tool, run:

./jdebloat.py setup jinline
./jdebloat.py run jinline

Directory Structure

  • results [Directory containing the benchmark results]
  • data [Contains misc. data used by the tools]
  • jdebloat.py [The script which runs JDebloat]
  • output [The output directory]
  • README.mkd [The setup README]
  • scripts [Contains scripts used by jdebloat.py to run the tools]
  • tools [Contains the JShrink, JReduce, and JInline tools]
    • javaq [Contains the javaq tool, used for data collection]
    • jinline [Contains the JInline tool]
      • README.md [The JInline tool README file]
    • jshrink [Contains the JShrink tool]
      • README.md [The JShrink README file]
    • jreduce [Contains the JReduce tool]
      • README.md [The JReduce README file]

Benchmark Results

We tested JDebloat on 25 benchmarks and found the following reductions:

Name Reduction
aragozin/jvm-tools 64.20%
ata4/disunity 25.64%
Bukkit/Bukkit 66.49%
eirslett/frontend-maven-plugin 99.99%
google/gson 30.05%
JakeWharton/DiskLruCache 20.20%
JakeWharton/retrofit1-okhttp3-client 22.70%
JakeWharton/RxReplayingShare 47.70%
JCTools/JCTools 90.70%
junit-team/junit4 20.21%
kevinsawicki/http-request 19.80%
mabe02/lanterna 24.99%
pagehelper/Mybatis-PageHelper 30.25%
pedrovgs/Algorithms 36.74%
qiujiayu/AutoLoadCache 71.02%
square/javapoet 20.51%
square/moshi 99.56%
takari/maven-wrapper 74.45%
alibaba/TProfiler 97.15%
dieforfree/qart4j 100.00%
dubboclub/dubbokeeper 80.09%
JakeWharton/RxRelay 27.80%
sockeqwe/fragmentargs 23.73%
tomighty/tomighty 29.13%
zeroturnaround/zt-zip 26.61%

The links to all of these repositories, as well as the commits we used, are listed in data/benchmarks.csv.

Making the Docker image

docker build -t jdebloat:latest .