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

ServiceLoaderTest.testSkipHookLoadedByDifferentClassloader failure #13534

Closed
Holmistr opened this issue Aug 6, 2018 · 5 comments · Fixed by #13541
Closed

ServiceLoaderTest.testSkipHookLoadedByDifferentClassloader failure #13534

Holmistr opened this issue Aug 6, 2018 · 5 comments · Fixed by #13541
Assignees
Labels
Source: Internal PR or issue was opened by an employee Team: Core Type: Test-Failure
Milestone

Comments

@Holmistr
Copy link
Contributor

Holmistr commented Aug 6, 2018

master (commit 4525ce5)

Failing constantly only on IBM JDK 8: https://hazelcast-l337.ci.cloudbees.com/view/Official%20Builds/job/Hazelcast-3.x-IbmJDK8/lastCompletedBuild/testReport/com.hazelcast.util/ServiceLoaderTest/testSkipHookLoadedByDifferentClassloader/

Other failures (with same stacktrace):
ServiceLoaderTest.testSkipHooksWithImplementingTheExpectedInterfaceButLoadedByDifferentClassloader
ServiceLoaderTest.testFailFastWhenHookDoesNotImplementExpectedInteface

Stacktrace:

java.lang.IllegalStateException: Cannot access final java.lang.Package java.lang.ClassLoader.getDefinedPackage(java.lang.String)
	at net.bytebuddy.dynamic.loading.ByteArrayClassLoader$PackageLookupStrategy$ForJava9CapableVm.apply(ByteArrayClassLoader.java:561)
	at net.bytebuddy.dynamic.loading.ByteArrayClassLoader$ClassDefinitionAction.run(ByteArrayClassLoader.java:439)
	at net.bytebuddy.dynamic.loading.ByteArrayClassLoader$ClassDefinitionAction.run(ByteArrayClassLoader.java:409)
	at java.security.AccessController.doPrivileged(AccessController.java:666)
	at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.findClass(ByteArrayClassLoader.java:262)
	at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:925)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:870)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:853)
	at java.lang.Class.forNameImpl(Native Method)
	at java.lang.Class.forName(Class.java:402)
	at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.load(ByteArrayClassLoader.java:220)
	at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$WrappingDispatcher.load(ClassLoadingStrategy.java:285)
	at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:120)
	at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79)
	at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4376)
	at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4362)
	at com.hazelcast.util.ServiceLoaderTest.newInterface(ServiceLoaderTest.java:243)
	at com.hazelcast.util.ServiceLoaderTest.testSkipHookLoadedByDifferentClassloader(ServiceLoaderTest.java:176)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
	at java.lang.reflect.Method.invoke(Method.java:508)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at com.hazelcast.test.FailOnTimeoutStatement$CallableStatement.call(FailOnTimeoutStatement.java:106)
	at com.hazelcast.test.FailOnTimeoutStatement$CallableStatement.call(FailOnTimeoutStatement.java:98)
	at java.util.concurrent.FutureTask.run(FutureTask.java:277)
	at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.IllegalAccessException: Class net.bytebuddy.dynamic.loading.ByteArrayClassLoader$PackageLookupStrategy$ForJava9CapableVm can not access a member of class java.lang.ClassLoader with modifiers "final"
	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:114)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:399)
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:391)
	at java.lang.reflect.Method.invoke(Method.java:501)
	at net.bytebuddy.dynamic.loading.ByteArrayClassLoader$PackageLookupStrategy$ForJava9CapableVm.apply(ByteArrayClassLoader.java:559)
	... 29 more

The failure is constant, actually much earlier, but because of Jenkins jobs migration, I'm reporting it now with quite a big delay, sorry about that.

@Holmistr Holmistr added this to the 3.11 milestone Aug 6, 2018
@kwart kwart self-assigned this Aug 6, 2018
@mdogan
Copy link
Contributor

mdogan commented Aug 6, 2018

This looks like an issue with bytebuddy. It tries to detect JVM capability using reflection:

public PackageLookupStrategy run() {
    try {
        return new PackageLookupStrategy.ForJava9CapableVm(ClassLoader.class.getDeclaredMethod("getDefinedPackage", String.class));
    } catch (Exception ignored) {
        return PackageLookupStrategy.ForLegacyVm.INSTANCE;
    }
}

So, if there's a method named getDefinedPackage in ClassLoader class, then it assumes that's a Java9CapableVm. But in pre-9 IBM JDKs, a package private getDefinedPackage method exists.
That's why bytebuddy thinks IBM JDK 8 as Java 9.

@mdogan
Copy link
Contributor

mdogan commented Aug 6, 2018

@mdogan
Copy link
Contributor

mdogan commented Aug 6, 2018

    public static void main(String[] args) throws Exception {
       System.err.println(ClassLoader.class.getDeclaredMethod("getDefinedPackage", String.class));
    }

Above code prints following on IBM Java 1.8.0_171

final java.lang.Package java.lang.ClassLoader.getDefinedPackage(java.lang.String)

Detailed spec:

java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 8.0.5.17 - pxa6480sr5fp17-20180627_01(SR5 FP17))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20180626_390413 (JIT enabled, AOT enabled)
OpenJ9   - 5cdc604
OMR      - a24bc01
IBM      - 21870d6)
JCL - 20180619_01 based on Oracle jdk8u171-b11

See raphw/byte-buddy#510

@mdogan
Copy link
Contributor

mdogan commented Aug 7, 2018

Fixed in byte-buddy 1.8.17

kwart added a commit to kwart/hazelcast that referenced this issue Aug 7, 2018
@kwart
Copy link
Member

kwart commented Aug 7, 2018

Thanks @mdogan for reporting the byte-buddy issue and initiating the quick release of version 1.8.17.

kwart added a commit to kwart/hazelcast that referenced this issue Aug 7, 2018
Holmistr pushed a commit that referenced this issue Aug 7, 2018
kwart added a commit to kwart/hazelcast that referenced this issue Aug 7, 2018
kwart added a commit that referenced this issue Aug 7, 2018
@mmedenjak mmedenjak added the Source: Internal PR or issue was opened by an employee label Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Internal PR or issue was opened by an employee Team: Core Type: Test-Failure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants