jpf-native:start
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| jpf-native:start [2009/05/14 20:53] – franck | jpf-native:start [2009/05/14 21:03] (current) – franck | ||
|---|---|---|---|
| Line 132: | Line 132: | ||
| Note that modeldirectory is the directory in which the model classes can be found. | Note that modeldirectory is the directory in which the model classes can be found. | ||
| - | If we run JPF, we get | + | If we run JPF, we get something like the following. |
| < | < | ||
| JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center | JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center | ||
| Line 161: | Line 161: | ||
| ===== Model Class and Native Peer Class ===== | ===== Model Class and Native Peer Class ===== | ||
| + | We can also " | ||
| + | <code java> | ||
| + | package java.util; | ||
| + | |||
| + | /** | ||
| + | * Model class of the constructor and the toString method of the Date class. | ||
| + | */ | ||
| + | public class Date | ||
| + | { | ||
| + | private long fastTime; | ||
| + | |||
| + | public Date() | ||
| + | { | ||
| + | this.fastTime = System.currentTimeMillis(); | ||
| + | } | ||
| + | |||
| + | native public String toString(); | ||
| + | } | ||
| + | </ | ||
| + | Note that we also model the constructor. | ||
| + | |||
| + | Whenever JPF encounters a native method, it looks for a corresponding | ||
| + | native peer class. | ||
| + | <code java> | ||
| + | package gov.nasa.jpf.jvm; | ||
| + | |||
| + | /** | ||
| + | * Native peer for the toString method of the Date class. | ||
| + | */ | ||
| + | public class JPF_java_util_Date | ||
| + | { | ||
| + | public static int toString(MJIEnv env, int objref) | ||
| + | { | ||
| + | return env.newString(env.getDateObject(objref).toString()); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | We have to ensure that the native peer class is part of the classpath | ||
| + | used by JPF and set the vm.bootclasspath appropriately for the model class. | ||
| + | |||
| + | If we run JPF, we get something like the following. | ||
| + | < | ||
| + | JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center | ||
| + | |||
| + | |||
| + | ====================================================== system under test | ||
| + | application: | ||
| + | |||
| + | ====================================================== search started: 5/14/09 5:02 PM | ||
| + | Thu May 14 17:02:54 EDT 2009 | ||
| + | |||
| + | ====================================================== results | ||
| + | no errors detected | ||
| + | |||
| + | ====================================================== statistics | ||
| + | elapsed time: | ||
| + | states: | ||
| + | search: | ||
| + | choice generators: | ||
| + | heap: gc=1, new=262, free=14 | ||
| + | instructions: | ||
| + | max memory: | ||
| + | loaded code: classes=66, methods=839 | ||
| + | |||
| + | ====================================================== search finished: 5/14/09 5:02 PM | ||
| + | </ | ||
jpf-native/start.1242334396.txt.gz · Last modified: by franck
