Categories: JPF

Installing and Running Java Path Finder (JPF)

The NASA AMES site has the necessary documentation for this procedure (and all else JPF). Nonetheless, I’m documenting the process here to save me some time the next time I need to do this since all commands will be in one spot.

For this project, I was running a Windows 7 box but these instructions should be easy to port to Linux other platforms. You will need to install the latest version of the Java Runtime Environment (JRE) and the Java Development Kit (JDK). Without the JDK installed (and included in your PATH environment variable), you will get the famous “javac is not recognized as an internal or external command.” These tools can be found on Sun’s website. Proceed to the command line and verify that these commands list the most up to date recent Java version available (JDK 6 Update 20 as of this posting).

javac -version
java -version

You will also need Mercurial to install JPF. For windows users, it may be easier to install TortoiseHg since it will automatically add the hg command to the PATH [needs confirmation]. On my system, I installed the JPF core into a JPF folder I created in my home folder. To do so, drop to the command line then:

cd %HOMEPATH%
mkdir jpf
cd jpf
hg clone http://babelfish.arc.nasa.gov/hg/jpf/jpf-core

To build the source and run the test suite:

cd jpf-core
bin/ant test

This ant script requires the JAVA_HOME environment variable to be set (on Windows anyway). I set it to my JDK installation path.

Note: for my initial checkout, I cloned http://babelfish.arc.nasa.gov/hg/jpf but expecting to get the whole tree, but the subrepositories were empty! All the extensions must be separately cloned. Before running the Racer example mentioned on the JPF page, you need to set up the site.properties file. This file should be placed in a folder called “.jpf” in the user’s home directory. Attempting to run the example before setting up this file will give you the error message: “gov.nasa.jpf.JPFClassLoaderException: no classpath entry for gov.nasa.jpf.JPF found (check site.properties)”.

cd %HOMEPATH%
mkdir .jpf
cd .jpf

echo # JPF site configuration > site.properties
echo # >> site.properties
echo jpf-core = ${user.home}/jpf/jpf-core >> site.properties
echo # >> site.properties
echo # numeric extension >> site.properties
echo jpf-numeric = ${user.home}/jpf/jpf-numeric >> site.properties
echo extensions+=${jpf-numeric} >> site.properties
echo # >> site.properties
echo # annotation-based program properties extension >> site.properties
echo jpf-aprop = ${user.home}/jpf/jpf-aprop >> site.properties
echo extensions+=,${jpf-aprop} >> site.properties
echo # >> site.properties
echo #... and all your other installed projects >> site.properties
echo # >> site.properties

Verify that site.properties has been successfully created. Now we can run the example:

java -jar build/RunJPF.jar src/examples/Racer.jpf

Et voila! You should now see output like:

JavaPathfinder v5.0 - (C) 1999-2007 RIACS/NASA Ames Research Center

====================================================== system under test
application: Racer.java

====================================================== search started: 7/1/10 5:51 PM
10
10

====================================================== error #1
gov.nasa.jpf.listener.PreciseRaceDetector
race for: "int Racer.d"
  main at Racer.main(Racer.java:16)
                "int c = 420 / racer.d;               // (4)"  : getfield
  Thread-0 at Racer.run(Racer.java:7)
                "d = 0;                               // (2)"  : putfield

====================================================== snapshot #1
thread index=0,name=main,status=RUNNING,this=java.lang.Thread@0,target=null,priority=5,lockCount=0,suspendCount=0
  call stack:
        at Racer.main(Racer.java:16)

thread index=1,name=Thread-0,status=RUNNING,this=java.lang.Thread@272,target=Racer@271,priority=5,lockCount=0,suspendCount=0
  call stack:
        at Racer.run(Racer.java:7)

====================================================== results
error #1: gov.nasa.jpf.listener.PreciseRaceDetector "race for: "int Racer.d"    main at Racer.main(Race..."

====================================================== statistics
elapsed time:       0:00:00
states:             new=9, visited=1, backtracked=4, end=2
search:             maxDepth=5, constraints=0
choice generators:  thread=8, data=0
heap:               gc=8, new=278, free=32
instructions:       2956
max memory:         15MB
loaded code:        classes=68, methods=988

====================================================== search finished: 7/1/10 5:51 PM

Article info




Leave a Reply

Your email address will not be published. Required fields are marked *