javapathfinder / jpf-core

JPF is an extensible software analysis framework for Java bytecode. jpf-core is the basis for all JPF projects; you always need to install it. It contains the basic VM and model checking infrastructure, and can be used to check for concurrency defects like deadlocks, and unhandled exceptions like NullPointerExceptions and AssertionErrors.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URLClassLoader unit tests fail under Windows

ghost-cai opened this issue · comments

I used the master branch.
gradle8.4
OpenJDK version 11
image
I have executed the command gradle build, and I got the test error.
image
image

java.lang.AssertionError: JPF found unexpected errors: gov.nasa.jpf.vm.NoUncaughtExceptionsProperty

Has the issue been fixed? I have saw the same error in this issue.
image

Hi,
"Temurin" is Eclipse's JDK; it seems to be compatible with OpenJDK except for URLClassLoader. Are you running the tests under Windows? Perhaps there is an incompatibility there (rather than with Temurin).

I used jpf-core under windows with Intellij Idea. I got the result mentioned above.I tried to execute gradle build in cmd. I got the same error.
image
And I can't use the jpf-core.
image
Can you give some advises?

This is likely because Windows' shell does not use standard "/" as directory separator, but a backslash instead. This can probably be addressed in JPF's model and native peer classes. As we don't have access to Windows, we cannot fix this, but we are happy to accept a patch that handles this issue.

All right. Although there is still the error mentioned above, I can executed the java -jar RunJPF.jar HelloWorld.jpf.
And I got the result:
image
However, I alter the "HelloWorld.java"
from :

public class HelloWorld {
  public static void main(String[] args){
    System.out.println("I won't say it!");
  }
}

to :

public class HelloWorld {
  public void save(){
    System.out.println("save function!");
  }
}

I got the result shown below.
屏幕截图 2023-12-20 105524
Is there must a main function in the tested .class? If not, what should I do?

Yes, JPF expects a regular Java application with a static main method as an entry point. If your code has no main method, you have to write one.

There are many class don't have "main function" in the jar of a project. Or, it can be said that a project usually has only one "main function". Can jpf test this jar? Can jpf test these classes? Can jpf used to a whole web project? Such as ,testing some interfaces.

JPF essentially performs a system test by default, but it can also be used to run unit tests. The latter mode is used to test JPF itself. Please see the wiki for more information.
To test the contents of a JAR file, you usually want to mix system tests (calling main with different parameters) and unit tests, as far as there is non-determinism in the form of thread scheduling or input choices.