Lab 5

Implement a listener, named LocalVariableIds, that prints the set of IDs of the local variables manipulated in the main method. A sample run can be found below. It shows what type of output your listener should produce. Here are some hints that may be useful for implementing your listener.

To compile your listener, use

javac -cp /cs/fac/packages/jpf/jpf-core/build/jpf.jar:. LocalVariableIds.java

or add /cs/fac/packages/jpf/jpf-core/build/jpf.jar as an external library to Eclipse.

To test your listener, you may want to use the following app.

public class LocalVariableIdsSample {
    public static void main(String[] args) {
	int i = 5;
	boolean b = true;
	double d = 3.0;
        i++;
        b = false;
    }
}

To run JPF on the above app, use the following configuration file.

target=LocalVariableIdsSample
classpath=.
listener=LocalVariableIds
native_classpath=/eecs/home/franck/

where /eecs/home/franck/ is the path to the directory in which LocalVariableIds.class can be found.

If the above configuration file is used with the above app, JPF should produce output similar to the following.

JavaPathfinder core system v8.0 (rev 32+) - (C) 2005-2014 United States Government. All rights reserved.


====================================================== system under test
LocalVariableIdsSample.main()

====================================================== search started: 2/8/18 12:04 PM

======================================================
Local variable ids
LocalVariableIdsSample.main([Ljava/lang/String;)V.3
LocalVariableIdsSample.main([Ljava/lang/String;)V.2
LocalVariableIdsSample.main([Ljava/lang/String;)V.1

====================================================== results
no errors detected

====================================================== statistics
elapsed time:       00:00:00
states:             new=1,visited=0,backtracked=1,end=1
search:             maxDepth=1,constraints=0
choice generators:  thread=1 (signal=0,lock=1,sharedRef=0,threadApi=0,reschedule=0), data=0
heap:               new=346,released=11,maxLive=0,gcCycles=1
instructions:       3165
max memory:         57MB
loaded code:        classes=60,methods=1324

====================================================== search finished: 2/8/18 12:04 PM

To receive feedback, submit your listener using the submit command before Tuesday February 12: submit 4315 lab5 LocalVariableIds.java