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

NoSuchMethodError: java.nio.StringCharBuffer.nextGetIndex

estebistec opened this issue · comments

Hello,

I'm running JPF on OpenJDK 1.8.0_362, and am getting the referenced NoSuchMethodError. I also tried OpenJDK 11.0.18 and got the same result. I also reproduced with JPF from head of mainline.

The simplest reproduction inside of a JUnit that can otherwise run JPF in the IDE:

        java.nio.charset.StandardCharsets.UTF_8.newEncoder().encode(java.nio.CharBuffer.wrap("heyo"));

The full stacktrace:

    [junit] gov.nasa.jpf.vm.NoUncaughtExceptionsProperty
    [junit] java.lang.NoSuchMethodError: java.nio.StringCharBuffer.nextGetIndex()I
    [junit]     at java.nio.StringCharBuffer.get(StringCharBuffer.java:76)
    [junit]     at sun.nio.cs.UTF_8$Encoder.encodeBufferLoop(UTF_8.java:645)
    [junit]     at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:693)
    [junit]     at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:579)
    [junit]     at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:802)
    [junit]     at REDACTED_MY_TEST_METHOD

This is unexpected, as we don't have model classes for java.nio.charset or java.nio.StringCharBuffer. We now have students working for GSoC who can look at such problems, maybe they can find the root cause.

Hello @cyrille-artho I would like to contribute here, can you please let me know whether this issue resolved or not?

No, it is not resolved yet, otherwise, we would have closed it.
Fixing the problem is simple, but creating an automated test that checks if it has been fixed is not. It would be great to have a test for this, but if it turns out to be too difficult to automate the test, just fixing the problem is fine, too.

Okay @cyrille-artho, Thanks for the information!

I want to pick this issue and I have successfully run jpf on my machine so can you tell me which class/file look into the issue.

The one-line example from the original submitter is likely the shortest example that shows the problem.
Look at our wiki page on how to write unit tests for JPF on how to encode this one-liner as a new unit test:
https://github.com/javapathfinder/jpf-core/wiki/Writing-JPF-tests
After that, you have a new (failing) test. Fixing this test will be a bit harder than one line of code.
The test fails because we don't model all the internal functionality that the Java library uses.
First, you have to analyze where a fix would be suitable:

  1. java.nio.charset.CharsetEncoder.encode
  2. java.nio.StringCharBuffer.get

We currently don't have model classes for either of these classes.
How complex are these classes? How complex are the functions in question? Does it make sense to replace a whole class with a model class here? If the effort is too big, we may prioritize other functions instead. But if one of these two classes (and functions) are easy to model, it may be worth creating another model class.