project COMP 790
Clone JPF-core : https://github.com/javapathfinder/jpf-core.git
JPF_CORE = <path-to-jpf-core>
Add the variable to the path : %JPF_CORE%\bin
Write a small Java program : ArrayTest.java
Write a JPF Configuration File : ArrayTest.jpf
Compile java program :
javac -cp "..\..\build\main" BankersAlgorithm.java (add classpath)
javac -cp "..\..\build\main;..\..\build\classes\java.base" ParallelBankersAlgorithm.java
To save output use : jpf BankersVerifier.jpf >> output.txt
(output = fileName)
Analyze the JPF Output
Alternatively, you can avoid compiling java program using javac everytime you make changes to java file.
java -jar /path/to/jpf-core/build/RunJPF.jar banker.jpf
Create a file: TestProgram.java
file with following content :
public class TestProgram {
public static void main(String[] args) {
int x = 1000000;
int y = 1000000;
int result = x * y; // Potential overflow
if (result < 0) { // If overflow occurs, result becomes negative
System.out.println("Overflow detected!");
} else {
System.out.println("Computation successful: " + result);
}
}
}
Create a file: TestProgram.jpf
// JPF configuration file
target=TestProgram
classpath=.
Open the terminal (or command prompt). Navigate to the folder where TestProgram.java
is located.
Compile the program: javac TestProgram.java
Run JPF: jpf TestProgram.jpf
Folder structure
BankerAlgo-FormalVerification/
│
├── jpf-core/
│ ├── build/
│ │ └── classes/
│ └── src/
│ └── project/
│ └── BankersVerifier.java
│ └── BankersVerifier.jpf
│ └── DynamicBankersVerifier.java
│ └── DynamicBankersVerifier.jpf
│
├── TestProgram.jpf
└── README.md