Java Pathfinder is a system to verify executable Java bytecode programs. JPF was developed at the NASA Ames Research Center and open sourced in 2005. The acronym JPF is not to be confused with the unrelated Java Plugin Framework project. The core of JPF is a Java Virtual Machine. JPF executes normal Java bytecode programs and can store, match and restore program states. Its primary application has been Model checking of concurrent programs, to find defects such as data races and deadlocks. With its respective extensions, JPF can also be used for a variety of other purposes, including
JPF has no fixed notion of state space branches and can handle both data and scheduling choices.
Example
The following system under test contains a simple race condition between two threads accessing the same variable d in statements and, which can lead to a division by zeroexception if is executed before public class Racer implements Runnable Without any additional configuration, JPF would find and report the division by zero. If JPF is configured to verify absence of race conditions, it will produce the following output, explaining the error and showing a counter example leading to the error JavaPathfinder v6.0 - RIACS/NASA Ames Research Centerapplication: Racer.java ...gov.nasa.jpf.listener.PreciseRaceDetector race for field Racer@13d.d main at Racer.main "int c = 420 / racer.d; " : getfield Thread-0 at Racer.run "d = 0; " : putfield---- transition #0 thread: 0 ... ---- transition #3 thread: 1 gov.nasa.jpf.jvm.choice.ThreadChoiceFromSet
JPF is an open system that can be extended in a variety of ways. The main extension constructs are
listeners - to implement complex properties
peer classes - to execute code at the host JVM level, which is mostly used to implement native methods
bytecode factories - to provide alternative execution semantics of bytecode instructions
choice generators - to implement state space branches such as scheduling choices or data value sets
serializers - to implement program state abstractions
publishers - to produce different output formats
search policies - to use different program state space traversal algorithms
JPF includes a runtime module system to package such constructs into separate JPF extension projects. A number of such projects are available from the main JPF server, including a symbolic execution mode, numeric analysis, race condition detection for relaxed memory models, user interface model checking and many more.
Limitations
JPF cannot analyze Java native methods. If the system under test calls such methods, these have to be provided within peer classes, or intercepted by listeners