# e-Knife: Java edition e-Knife is a program slicer for Java programs based on the Expression Dependence Graph (EDG). You can also try this project through [the online demo](https://mist.dsic.upv.es/e-knife-java/). This project consists of three modules: * e-Knife: the frontend for the EDG, which implements the necessary tools to slice Java programs. * EDG: the generic library that implements the graph and slicing techniques. * Miscellaneous: various shared utilities. ## Compilation Requirements: Java JDK ≥ 11 and Maven. Download this project, then open a terminal inside the extracted folder and compile it with the following command: ```bash mvn package ``` You'll find a file named `e-Knife-...-jar-with-dependencies.jar` inside the `e-Knife/target/` folder. ## Usage Requirements: Java JRE ≥ 11. Download the `.jar` file from the releases page or compile the project. You'll probably want to generate slices, so you should run e-Knife. Run it without args to obtain a list and explanation of arguments. ``` java -jar path/to/eknife.jar ``` There are 5 mandatory parameters. If one of them is missing the program will do nothing and print a help prompt. - `-ip `: the file to be sliced. - `-li `: the line where the slicing criterion is located. - `-na `: the variable of the slicing criterion. - `-oc `: the occurrence of the variable in the line (use 1 unless it appears more than one). - `-op `: the file where the slice should be saved. For example, to slice `Example.java` with the slicing criterion `11, sum` and save the slice to `ExampleSliced.java`, you can use the following command: ``` java -jar path/to/eknife.jar -ip Example.java -li 11 -na sum -oc 1 -op ExampleSliced.java ``` ### View the sliced graph To produce a graph, you must specify the optional argument `-pdf `. In non-trivial programs, the graph can be too complicated to be useful. You can either: 1. Use the corresponding options to show/hide certain types of arcs (e.g., `-summary`, `-allarcs`, `-control`...). 2. Output the graph to a dot file using `-dot `, and then manually delete unwanted arcs and/or use an interactive graphviz viewer, such as [XDot][xdot]. [xdot]: https://github.com/jrfonseca/xdot.py ## Import into an IDE In most Java IDEs you'll find an option to import an existing Maven project, and thus load the project structure and settings from the `pom.xml` files. Otherwise, you can treat each folder (EDG, e-Knife and Miscellanea) as a separate module, with the following dependencies: * e-Knife requires EDG and Miscellanea. * EDG requires Miscellanea. * Miscellanea has no dependencies. ## License This project is licensed under GNU Affero Public License (Version 3.0). You should have received a copy of the GNU Affero Public License along with this program. If not, see https://www.gnu.org/licenses.