DOI: 10.6084/m9.figshare.13664039
title: Where to Handle an Exception? Recommending Exception Handling Locations from a Global Perspective

description: <b>The Replication Package (data & code) AND A Simple Demo of EHAdvisor.</b><b><br></b><b>######## </b><b>Introduction of Replication Package (replication.zip) ########</b><b><br></b><b>#README</b><br>This is the replication package of the paper **"Where to Handle an Exception? Recommending Exception Handling Locations from a Global Perspective"**.<br><b>## Content</b><br>This package includes the codes to replicate the experiments in the paper as following:<br>* `Graph`: This folder includes the codes to use AST Parser JDT to parse the source codes in a project and construct the numerical samples that are represented with the four features (i.e. architectural feature, project feature, functional feature, and exception feature). The entry is `App.java`. You can use it to construct samples for any other Java project.* `Dataset`: For the convenience to replicate, we release the extracted samples from the 29 popular Java projects. This folder includes the data we adopt in the experiments.* `Train`: This folder includes the scripts to train the binary classification model with AutoGluon.* `FeatImportanceAnalysis`: This folder includes the scripts to calculate the importance score of each feature with AutoGluon.<br><b>## Replication Instruction</b><br><b>### Package Requirement</b><br>* Python 3.8* AutoGluon 0.15<br>For more details about the package requiment, we provide a package list in `requirements.txt`. You can type the command `pip install -r requirements.txt` to easily construct the experiment environment.<br><b>### Exepriment Instruction:</b><br>* Train and apply the classification model with a specific scenario (i.e. one of across-project, intra-project, and intra-project+) as following, where PROJECTID is the id of the target project that request for the recommendation. This step will generate a binary-classification model as well as the predicted catch probability on each method for each its related exception. * Across-project recommendation: Run the `across.py` script in `train` directory as `python across.py --train_id=PROJECTID`. * Intra-project recommendation: Run the `intra.py` script in `train` directory as `python intra.py --train_id=PROJECTID`. * Intra-project+ recommendation: Run the `intraplus.py` script in `train` directory as `python intraplus.py --train_id=PROJECTID`.* Run the `top.py` script in `train` directory to get the recommendation result and the recommendation performance in terms of SuccRate@1,2,3.* Other: * You can run the `calcImportance.py` script in `FeatImportanceAnalysis` directory to get the importance score of each type of featres with AutoGluon. * You can specify the training time limit and the output directory for AutoGluon through changing the value of `time_limites` and `oupput_directory` in `across.py`, `intra.py`, `intraplus.py`, and `calcImportance.py`.<br><b>######## </b><b>Introduction of Simple Demo </b><b>(demo.zip)</b><b> ########</b><b><br></b><b># README</b><b><br></b>This is the simple demo of the paper **"Where to Handle an Exception? Recommending Exception Handling Locations from a Global Perspective"**. <br>We release this demo to simply illustrate the preliminary use flow of EHAdvisor.<br>Given a project and a specific method, this demo will output the location recommendations to handle the exceptions thrown by this method on all its call chains.<br><b>## Usage</b><br>1. Obtain a base binary-classification model. You can use a pre-trained model we release on our webpage or train a model with `python trainModel.py` (please refer to the replication package instruction for the details about training).2. Run `python tools.py` to execute the demo script.3. Input the path to the source code of the target project after the script prompts "Please input the path of the source folder:", e.g., `shiro`.4. Input the path to the description text of the target project after the script prompts "Please input the path of the project document file:", e.g., `shiro/readme.txt`.5. Input the method requiring for the location recommendations after the scripts promts "Please input the name of method:", e.g., `org.apache.shiro.cache.ehcache.EhCacheManager$ensureCacheManager`.6. Then, you will get the location recommendations to handle the exceptions thrown by this method on all its call chains.<br><br>