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

`String.equals(Object)` makes JPF on Java 11 crash

quadhier opened this issue · comments

Hi @cyrille-artho , I found a bug in implementation of String.equals(Object) in JPF and it only exists on master branch (for Java 11). A simple program like the following one would reveal this issue.

public class StringCmp {
  public static void main (String[] args) {
    System.out.println("a".equals(new Object()));
  }
}

The fix is straightforward, yet it requires some knowledge of native peers. I think it would be a good candidate for "good first issue". If you agree, perhaps you could tag this issue with the label, allowing new contributors the opportunity to resolve the bug.

To fix the bug that only exists on the master branch when using String.equals(Object), alter the code in the StringCmp class to correctly compare a String with an Object.

Hi,
Thank you for finding the bug. In this case, adding a test and fix is indeed easy (as you have already provided the test and adding a test merely involves using the skeleton from https://github.com/javapathfinder/jpf-core/wiki/Writing-JPF-tests).
This fix involves a small change in the native peer.
I'll mark it as a good issue for beginners.

Hi , @quadhier
I known how to solve this type of problem but unable to get the file which you are talking about .

Hi , @quadhier I known how to solve this type of problem but unable to get the file which you are talking about .

Which file? If you mean StringCmp.java, I have shown its source code above. Run it with JPF and you could reproduce the crash.

Hi @cyrille-artho ,
i know the problem's solution but unable to get file which of file contain this bug(#439) , please help me..

In this case, String needs a new equals method. You can find the model class for String in src/classes.

@cyrille-artho If you would like, you can assign this issue to me!

Please go ahead and try to add a test and fix.