Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalAccessError: JPF_java_util_Random cannot access class jdk.internal.misc.Unsafe #107

Open
gayanW opened this issue Jul 20, 2018 · 3 comments

Comments

@gayanW
Copy link
Collaborator

gayanW commented Jul 20, 2018

Runtime error "java.lang.IllegalAccessError: class gov.nasa.jpf.vm.JPF_java_util_Random (in unnamed module) cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module"

[junit] java.lang.IllegalAccessError: class gov.nasa.jpf.vm.JPF_java_util_Random (in unnamed module @0x16f7b4af) cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @0x16f7b4af
[junit]     at gov.nasa.jpf.vm.JPF_java_util_Random.<clinit>(JPF_java_util_Random.java:99)
[junit]     at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[junit]     at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[junit]     at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[junit]     at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
[junit]     at gov.nasa.jpf.vm.NativePeer.getInstance(NativePeer.java:174)
[junit]     at gov.nasa.jpf.vm.NativePeer.getInstance(NativePeer.java:159)
[junit]     at gov.nasa.jpf.vm.NativePeer.getNativePeer(NativePeer.java:145)
[junit]     at gov.nasa.jpf.vm.ClassInfo.loadNativePeer(ClassInfo.java:834)
[junit]     at gov.nasa.jpf.vm.ClassInfo.resolveAndLink(ClassInfo.java:553)
[junit]     at gov.nasa.jpf.jvm.JVMClassInfo.<init>(JVMClassInfo.java:625)
@dosarudaniel
Copy link

dosarudaniel commented Jan 29, 2024

Hi @cyrille-artho, I am facing a similar issue while running: java -jar build/RunJPF.jar src/examples/Rand.jpf

Has this issue been solved or should I open a new one ?

Thanks!

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


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

====================================================== search started: 1/29/24, 7:33 PM
[WARNING] orphan NativePeer method: jdk.internal.misc.Unsafe.getUnsafe()Lsun/misc/Unsafe;
computing c = a/(b+a - 2)..
java.lang.IllegalAccessError: class gov.nasa.jpf.vm.JPF_java_util_Random (in unnamed module @0x1bd4fdd) cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @0x1bd4fdd
	at gov.nasa.jpf.vm.JPF_java_util_Random.<clinit>(JPF_java_util_Random.java:99)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at gov.nasa.jpf.vm.NativePeer.getInstance(NativePeer.java:174)
	at gov.nasa.jpf.vm.NativePeer.getInstance(NativePeer.java:159)
	at gov.nasa.jpf.vm.NativePeer.getNativePeer(NativePeer.java:145)
	at gov.nasa.jpf.vm.ClassInfo.loadNativePeer(ClassInfo.java:845)
	at gov.nasa.jpf.vm.ClassInfo.resolveAndLink(ClassInfo.java:555)
	at gov.nasa.jpf.jvm.JVMClassInfo.<init>(JVMClassInfo.java:772)
	at gov.nasa.jpf.jvm.JVMClassFileContainer$JVMClassFileMatch.createClassInfo(JVMClassFileContainer.java:59)
	at gov.nasa.jpf.jvm.JVMClassFileContainer$JVMClassFileMatch.createClassInfo(JVMClassFileContainer.java:34)
	at gov.nasa.jpf.vm.ClassLoaderInfo.getResolvedClassInfo(ClassLoaderInfo.java:356)
	at gov.nasa.jpf.vm.SystemClassLoaderInfo.getResolvedClassInfo(SystemClassLoaderInfo.java:148)
	at gov.nasa.jpf.vm.SystemClassLoaderInfo.loadClass(SystemClassLoaderInfo.java:183)
	at gov.nasa.jpf.vm.ClassInfo.resolveReferencedClass(ClassInfo.java:2485)
	at gov.nasa.jpf.vm.ThreadInfo.resolveReferencedClass(ThreadInfo.java:1243)
	at gov.nasa.jpf.jvm.bytecode.NEW.execute(NEW.java:55)
	at gov.nasa.jpf.vm.ThreadInfo.executeInstruction(ThreadInfo.java:1910)
	at gov.nasa.jpf.vm.ThreadInfo.executeTransition(ThreadInfo.java:1861)
	at gov.nasa.jpf.vm.SystemState.executeNextTransition(SystemState.java:765)
	at gov.nasa.jpf.vm.VM.forward(VM.java:1721)
	at gov.nasa.jpf.search.Search.forward(Search.java:937)
	at gov.nasa.jpf.search.DFSearch.search(DFSearch.java:79)
	at gov.nasa.jpf.JPF.run(JPF.java:613)
	at gov.nasa.jpf.JPF.start(JPF.java:189)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at gov.nasa.jpf.tool.Run.call(Run.java:80)
	at gov.nasa.jpf.tool.RunJPF.main(RunJPF.java:116)
danidosa@daniel-vm:~/jpf-core$ java -version
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

@cyrille-artho cyrille-artho reopened this Jan 30, 2024
@cyrille-artho
Copy link
Member

This works now, in a sense. But I agree that it is not a very obvious way to make this work. You have to specify the --add-opens directive when running JPF:

java --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -jar build/RunJPF.jar src/examples/Rand.jpf

Perhaps the best solution is to add this to bin/jpf, as we currently only use this option for the unit tests? (The random number generator is not used very often in programs that we run JPF on, so we had not run into this in real-life JPF usage since upgrading to Java 11.)

@dosarudaniel
Copy link

Thank you @cyrille-artho, indeed, if I run the example like to suggested I do not see the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants