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:56] – franck | jpf-native:start [2009/05/14 21:03] (current) – franck | ||
|---|---|---|---|
| Line 161: | Line 161: | ||
| ===== Model Class and Native Peer Class ===== | ===== Model Class and Native Peer Class ===== | ||
| - | We can also model the | + | We can also "model" |
| <code java> | <code java> | ||
| package java.util; | package java.util; | ||
| /** | /** | ||
| - | * Model class | + | * Model class of the constructor and the toString method of the Date class. |
| */ | */ | ||
| public class Date | public class Date | ||
| Line 180: | Line 179: | ||
| native public String toString(); | 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.1242334578.txt.gz · Last modified: by franck
