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

JPF fails with java.lang.IllegalArgumentException: Null charset name

aoli-al opened this issue · comments

Hi, I'm trying to use JPF to run the following simple program

import java.nio.file.Path;
public class BoundedBuffer {
  public static void main(String [] args) {
    Path.of("/tmp");
  }
}

I got the following exception:

JavaPathfinder core system v8.0 (rev 1a704e1d6c3d92178504f8cdfe57b068b4e22d9c) - (C) 2005-2014 United States Government. All rights reserved.


====================================================== system under test
BoundedBuffer.main()

====================================================== search started: 12/21/23, 3:01 PM
[WARNING] orphan NativePeer method: jdk.internal.misc.Unsafe.getUnsafe()Lsun/misc/Unsafe;

====================================================== error 1
gov.nasa.jpf.vm.NoUncaughtExceptionsProperty
java.lang.IllegalArgumentException: Null charset name
	at java.nio.charset.Charset.lookup(Charset.java:455)
	at java.nio.charset.Charset.forName(Charset.java:526)
	at sun.nio.fs.Util.<clinit>(Util.java:40)
	at sun.nio.fs.UnixFileSystem.<init>(UnixFileSystem.java:51)
	at sun.nio.fs.LinuxFileSystem.<init>(LinuxFileSystem.java:39)
	at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:46)
	at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:39)
	at sun.nio.fs.UnixFileSystemProvider.<init>(UnixFileSystemProvider.java:56)
	at sun.nio.fs.LinuxFileSystemProvider.<init>(LinuxFileSystemProvider.java:41)
	at sun.nio.fs.DefaultFileSystemProvider.<clinit>(DefaultFileSystemProvider.java:35)
	at java.nio.file.FileSystems.getDefault(FileSystems.java:185)
	at java.nio.file.Path.of(Path.java:147)
	at BoundedBuffer.main(BoundedBuffer.java:121)


====================================================== snapshot #1
thread java.lang.Thread:{id:0,name:main,status:RUNNING,priority:5,isDaemon:false,lockCount:0,suspendCount:0}
  owned locks:java.lang.Class@20b,java.lang.Class@278
  call stack:
	at sun.nio.fs.Util.<clinit>(Util.java:40)
	at sun.nio.fs.UnixFileSystem.<init>(UnixFileSystem.java:51)
	at sun.nio.fs.LinuxFileSystem.<init>(LinuxFileSystem.java:39)
	at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:46)
	at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:39)
	at sun.nio.fs.UnixFileSystemProvider.<init>(UnixFileSystemProvider.java:56)
	at sun.nio.fs.LinuxFileSystemProvider.<init>(LinuxFileSystemProvider.java:41)
	at sun.nio.fs.DefaultFileSystemProvider.<clinit>(DefaultFileSystemProvider.java:35)
	at java.nio.file.FileSystems.getDefault(FileSystems.java:185)
	at java.nio.file.Path.of(Path.java:147)
	at BoundedBuffer.main(BoundedBuffer.java:121)


====================================================== results
error #1: gov.nasa.jpf.vm.NoUncaughtExceptionsProperty "java.lang.IllegalArgumentException: Null charset n..."

====================================================== statistics
elapsed time:       00:00:00
states:             new=1,visited=0,backtracked=0,end=0
search:             maxDepth=1,constraints=0
choice generators:  thread=1 (signal=0,lock=1,sharedRef=0,threadApi=0,reschedule=0), data=0
heap:               new=691,released=0,maxLive=0,gcCycles=0
instructions:       11128
max memory:         500MB
loaded code:        classes=114,methods=2364

====================================================== search finished: 12/21/23, 3:01 PM

Could you please help me to fix this issue?

This exception happens because an internal default setting is set or initialized by the Java library, but not by the libraries that JPF uses. This can be because an existing model class (such as the classes in `src/classes/modules/java.base/java/nio) does not set a certain field. However, without further investigation, it is difficult to tell what the root cause is.
In any case, thanks to your report, we have a reproducible test for this.

Ideally, we can fix this by changing an existing class (in the model classes or a native peer class). If there is no way to fix it there, a new model class (in package java.nio.charset or java.nio.file) can fix the problem, at the expense of having an additional model class to maintain.

@cyrille-artho Hi, Can I fix this issue ?

Yes, please give it a try.