IllegalAccessError: class jdk.test.lib.Utils cannot access class jdk.internal.misc.Unsafe

Gustavo Romero gromero at linux.vnet.ibm.com
Mon Aug 29 22:06:51 UTC 2016


Hi David,

On 25-08-2016 23:46, David Holmes wrote:
> I'm at a loss to understand how the same test, with the same jtreg and JDK version can fail due to a module access error on some systems but not others. Makes no sense to me at all.
> 
> Even if you file a bug we can't investigate it as it doesn't happen here.

The issue occurs at runtime. Take x64 for instance, if the predicate
CPUInfo.hasFeature("rtm") && Platform.isServer() is False, then test() method in
CommandLineOptionTest class will not run the tests since it contains the
following check (isServer() is always True, I'm just testing on server):

if (predicate.getAsBoolean()) {
    runTestCases();
}

For instance, predicate here:
http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/file/64840dbba932/test/compiler/rtm/locking/TestRTMAbortRatio.java#l64

SupportedCPU() => CPUInfo.hasFeature("rtm"):
http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/file/64840dbba932/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java#l36

SupportedVM() => Platform.isServer():
http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/file/64840dbba932/test/compiler/testlibrary/rtm/predicate/SupportedVM.java#l34

test() method:
http://hg.openjdk.java.net/jdk9/hs-comp/file/9a47ecd3eeb9/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java#l515

It means that if RTM is not available the tests will return just fine, hence
they pass on non-RTM CPUs, without the named/unnamed access error.

In that sense if we make the following change (to verify), the tests will pass on a CPU
with RTM support:

diff -r 64840dbba932 test/compiler/testlibrary/rtm/predicate/SupportedCPU.java
--- a/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java Mon Aug 29 17:15:20 2016 +0000
+++ b/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java Mon Aug 29 17:38:20 2016 -0400
@@ -33,6 +33,6 @@
     @Override
     public boolean getAsBoolean() {
         if (Platform.isPPC()) { return CPUInfo.hasFeature("tcheck"); }
-        return CPUInfo.hasFeature("rtm");
+        return !CPUInfo.hasFeature("rtm"); // Return False if CPU has RTM support, passing the tests.
     }
 }


> That said a change has just been pushed (jdk9/hs ) think) that moves the Unsafe access out of Utils so that tests using Utils no longer need to access the jdk.internal module. So that might fix your
> problem.
> 

http://hg.openjdk.java.net/jdk9/hs-comp/rev/ed4e02fb36c3 did not fix the problem,
so I'm filing a bug as Dmitry instructed. Thanks for letting me know about that
changeset.


Regards,
Gustavo



More information about the hotspot-dev mailing list