lab2
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| lab2 [2016/01/13 02:42] – created franck | lab2 [2017/01/30 13:51] (current) – franck | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Read the notes. | + | ====== Lab 2 ====== |
| + | |||
| + | |||
| + | * In your home directory create a directory named .jpf (note that the name of the directory starts with a dot). | ||
| + | * In the created directory, create a file named site.properties with the following contents. | ||
| + | < | ||
| + | # JPF site configuration | ||
| + | jpf-core=/ | ||
| + | extensions=${jpf-core} | ||
| + | </ | ||
| + | * In your home directory create a directory name 4315. | ||
| + | * In the created directory 4315, create a directory named lab2. | ||
| + | * In the created directory lab2, create the class RandomFraction with the following content. | ||
| + | <code java> | ||
| + | import java.util.Random; | ||
| + | |||
| + | public class RandomFraction | ||
| + | { | ||
| + | public static void run() | ||
| + | { | ||
| + | Random random = new Random(System.currentTimeMillis()); | ||
| + | System.out.println(1 / random.nextInt(1000000)); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | * Compile the RandomFraction | ||
| + | * In the created directory lab2, create the class RandomFractionTest with the following content. | ||
| + | <code java> | ||
| + | public class RandomFractionTest | ||
| + | { | ||
| + | public static void main(String[] args) | ||
| + | { | ||
| + | RandomFraction.run(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | * Compile the RandomFractionTest class. | ||
| + | * Run the RandomFractionTest class. | ||
| + | * Create the file RandomFractionTest.jpf with the following content. | ||
| + | < | ||
| + | target=RandomFractionTest | ||
| + | classpath=. | ||
| + | </ | ||
| + | * Run Java PathFinder (JPF) on RandomFractionTest by running | ||
| + | < | ||
| + | jpf RandomFractionTest.jpf | ||
| + | </ | ||
| + | It should produce output similar to the following. | ||
| + | < | ||
| + | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
| + | |||
| + | |||
| + | ====================================================== system under test | ||
| + | RandomFractionTest.main() | ||
| + | |||
| + | ====================================================== search started: 1/14/17 12:06 PM | ||
| + | 0 | ||
| + | ====================================================== results | ||
| + | no errors detected | ||
| + | |||
| + | ====================================================== statistics | ||
| + | elapsed time: | ||
| + | states: | ||
| + | search: | ||
| + | choice generators: | ||
| + | heap: | ||
| + | instructions: | ||
| + | max memory: | ||
| + | loaded code: classes=62, | ||
| + | |||
| + | ====================================================== search finished: 1/14/17 12:06 PM | ||
| + | </ | ||
| + | * To the file RandomFractionTest.jpf add the following. | ||
| + | < | ||
| + | cg.enumerate_random=true | ||
| + | </ | ||
| + | * Run JPF on RandomFractionTest again. | ||
| + | < | ||
| + | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
| + | |||
| + | |||
| + | ====================================================== system under test | ||
| + | RandomFractionTest.main() | ||
| + | |||
| + | ====================================================== search started: 1/14/17 12:19 PM | ||
| + | |||
| + | ====================================================== error 1 | ||
| + | gov.nasa.jpf.vm.NoUncaughtExceptionsProperty | ||
| + | java.lang.ArithmeticException: | ||
| + | at RandomFraction.run(RandomFraction.java: | ||
| + | at RandomFractionTest.main(RandomFractionTest.java: | ||
| + | |||
| + | |||
| + | ====================================================== snapshot #1 | ||
| + | thread java.lang.Thread: | ||
| + | call stack: | ||
| + | at RandomFraction.run(RandomFraction.java: | ||
| + | at RandomFractionTest.main(RandomFractionTest.java: | ||
| + | |||
| + | |||
| + | ====================================================== results | ||
| + | error #1: gov.nasa.jpf.vm.NoUncaughtExceptionsProperty " | ||
| + | |||
| + | ====================================================== statistics | ||
| + | elapsed time: | ||
| + | states: | ||
| + | search: | ||
| + | choice generators: | ||
| + | heap: | ||
| + | instructions: | ||
| + | max memory: | ||
| + | loaded code: classes=66, | ||
| + | |||
| + | ====================================================== search finished: 1/14/17 12:19 PM | ||
| + | </ | ||
| - | Bonus marks: for each mistake in the notes that first reported by email, you receive 0.1 bonus mark, up to a maximum of 1.5 in total. | ||
lab2.1452652937.txt.gz · Last modified: by franck
