Analyze Self-Made Test Cases by Tai-e

We encourage you to write your own Java classes as test cases and analyze them by the analysis algorithm you implement. This will help you debug and understand the analysis algorithm better. In this document, we introduce how to use Tai-e to analyze the classes you write and how to deal with common problems.

How to Analyze the Classes You Write by Tai-e?

Actually we have explained this problem in Set Up Tai-e Assignments. Assuming you wrote a class and placed it in path/to/class/, then you can analyze it by running the pascal.taie.Assignment class provided in each assignment with arguments -cp /path/to/class/ -m A.

The option -m can only specify one class for the analysis, i.e., the main class of your Java program. However, it does not mean that Tai-e can only analyze the code in that certain class. If the class uses other classes under the path specified by -cp, Tai-e will analyze them together.

How to Deal With Frontend Errors and Unexpected IRs?

As mentioned in Set Up Tai-e Assignments, currently Tai-e leverages Soot frontend to parse Java programs and assist IR building. If the class you write is syntactically correct, but Tai-e still throws SootFrontendException or generates unexpected IRs (e.g., some statements in the source code are missing) when analyzing it, it is most likely that you use some language features that are not supported by Soot frontend for .java (this frontend can only partially support Java version up to 7, and is not very robust).

For those problems, the easiest solution is to compile the class you write into bytecode (.class) via Java compiler, and then let Tai-e analyze the .class files, so that Tai-e will use the Soot frontend for .class to parse the program. (Note: Although Soot frontend for .class is more robust, it does not keep variable names in the source code, and thus makes the generated IR less readable).

How to Analyze the Bytecode (.class) by Tai-e?

Analyzing .class files is as simple as analyzing the Java source files. Assuming the compiled A.class resides in path /path/to/class/, you just need to run pascal.taie.Assignment with arguments -cp /path/to/class/ -m A.

If both the Java source code (.java) and the bytecode (.class) of a class exist in the same path, Tai-e will preferentially choose the bytecode to analyze. So you just need to to put the compiled bytecode into the same path of the source code, and then use the same arguments to run the analysis.

Last Updated: