简体   繁体   English

Java路径查找器NumericValueChecker

[英]Java Path Finder NumericValueChecker

I am trying to learn Java Path Finder (JPF). 我正在尝试学习Java路径查找器(JPF)。 I downloaded the JPF and build it. 我下载并构建了JPF。 Currently I have jpf-core folder which has example .java files together with their corresponding .jpf files. 目前,我有jpf-core文件夹,其中包含示例.java文件以及它们相应的.jpf文件。 My goal is to create a new basic .java file and check whether a specific value in this file exceeds the max-bound I specified in the .jpf file. 我的目标是创建一个新的基本.java文件,并检查该文件中的特定值是否超过了我在.jpf文件中指定的最大限制。

In the examples folder there is .java file called NumericValueCheck.java which is exactly what I want, and it works as expected. 在examples文件夹中,有一个名为NumericValueCheck.java的.java文件正是我想要的文件,它可以按预期工作。 (finds when the value exceeds the bound) (在值超出界限时查找)

NumericValueCheck.java NumericValueCheck.java

public class NumericValueCheck {
  public static void main (String[] args){
    double someVariable;
    someVariable = 42;  
    someVariable = 60; 
  }
}

NumericValueCheck.jpf NumericValueCheck.jpf

target = NumericValueCheck

listener = .listener.NumericValueChecker

# NumericValueChecker configuration
range.vars = 1
range.1.var = NumericValueCheck.main(java.lang.String[]):someVariable
range.1.min = 0
range.1.max = 42

However, I created a new .java file and named it " BasicCheck.java ". 但是,我创建了一个新的.java文件,并将其命名为“ BasicCheck.java ”。 Here is the code inside it; 这是其中的代码;

public class BasicCheck {
public static void main(String[] args){
    double result;
    result = 60;
    result = 110;
    }
}

Here are the properties in BasicCheck.jpf ; 这是BasicCheck.jpf中的属性;

target = BasicCheck

listener = .listener.NumericValueChecker

# NumericValueChecker configuration
range.vars = 1
range.1.var = BasicCheck.main(java.lang.String[]):result
range.1.min = 0
range.1.max = 60

I compiled the BasicCheck.java using javac BasicCheck.java in a separate directory. 我在单独的目录中使用javac BasicCheck.java编译了BasicCheck.java。 Then I copy "BasicCheck.java" and "BasicCheck.jpf" to examples folder of jpf-core where NumericValueCheck.java and NumericValueCheck.jpf also in the same place. 然后,将“ BasicCheck.java”和“ BasicCheck.jpf”复制到jpf-core的示例文件夹中,其中NumericValueCheck.java和NumericValueCheck.jpf也在同一位置。 I also copy "BasicCheck.class" to jpf-core/build/examples directory where "NumericValueCheck.class" also in the same place. 我还将“ BasicCheck.class”复制到jpf-core/build/examples目录中,其中“ NumericValueCheck.class”也位于同一位置。

However, when I run the command java -jar build/RunJPF.jar src/examples/BasicCheck.jpf , it can't find any error. 但是,当我运行命令java -jar build/RunJPF.jar src/examples/BasicCheck.jpf ,找不到任何错误。 The result is "no error detected". 结果是“未检测到错误”。 It should detect 110 which is bigger than the upper bound 60. 它应检测到大于上限60的110。

Why is it not working? 为什么不起作用? Do I need to add something extra to my new BasicCheck.java or BasicCheck.jpf ? 我是否需要在我的新BasicCheck.java或BasicCheck.jpf中添加其他内容?

Thanks in advance. 提前致谢。

I found the solution after a long effort. 经过长时间的努力,我找到了解决方案。 The solution is simple. 解决方案很简单。

Put BasicCheck.java and BasicCheck.jpf under the directory jpf-core/src/examples . BasicCheck.javaBasicCheck.jpf放在jpf-core/src/examples目录下。

Do NOT compile to source using javac . 不要编译使用到源javac Open the terminal and cd to jpf-core directory. 打开终端,然后进入cdjpf-core目录。 Then type the following command: ./gradlew buildJars . 然后键入以下命令: ./gradlew buildJars

That's it. 而已。 Now you can use the command java -jar build/RunJPF.jar src/examples/BasicCheck.jpf to run Java Path Finder. 现在,您可以使用命令java -jar build/RunJPF.jar src/examples/BasicCheck.jpf运行Java路径查找器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM