Git Product home page Git Product logo

Comments (16)

oleksiyp avatar oleksiyp commented on May 15, 2024 1

I got rid of shadowing for bytebuddy, so now it is just a dependency.
Can you try it via snapshot repository (GRADLE):

repositories {
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

dependencies {
    compile "io.mockk:mockk:1.6.2-SNAPSHOT"
}

Mockito as well should use none shadowed version: mockito-core (not mockito-all)

from mockk.

oleksiyp avatar oleksiyp commented on May 15, 2024 1

@patrickcousins ok, then time to put it to release. great. thanks!

from mockk.

binkley avatar binkley commented on May 15, 2024 1

Builds cleanly on Windows 10 as well (above test was on latest MacOS). Both are Java 9.

from mockk.

oleksiyp avatar oleksiyp commented on May 15, 2024

Do you have any ideas why this is happening?
I see you are using shade plugin.
Maybe it's because of it

Is on the same run mockito-kotlin is used?
Because I guess it is possible it is conflicting one with another.
Can you isolate the test and run only it?

from mockk.

binkley avatar binkley commented on May 15, 2024

@oleksiyp I'll try to reproduce this at home this evening. The "dylib" is a macos thing (home is Windows). And I'll try out the other combinations.

from mockk.

binkley avatar binkley commented on May 15, 2024

This worked OK at home on Windows 10 and Java 9.

I'll try to reproduce tomorrow at work with MacOS and Java 8.

from mockk.

binkley avatar binkley commented on May 15, 2024

Interestingly, I got mockito on a different test for possibly similar ByteBuddy reasons. So that would imply: don't run both mock frameworks in the same project. :)

from mockk.

oleksiyp avatar oleksiyp commented on May 15, 2024

Thanks for such investigation. This is kind of sad. You can't try mockk while still having mockito. Maybe that is because of shading bytebuddy. I'll try to add it as a dependency and possibly it'll resolve this issue

from mockk.

oleksiyp avatar oleksiyp commented on May 15, 2024

Tomorrow... now time to sleep 😃

from mockk.

patrickcousins avatar patrickcousins commented on May 15, 2024

In case it might be helpful I am getting a similar issue:

java.lang.ExceptionInInitializerError
	at (test class)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	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 org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
	at com.sun.proxy.$Proxy3.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Error during attachment using: io.mockk.shadowed.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@ffd14022
	at io.mockk.shadowed.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:378)
	at io.mockk.shadowed.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:352)
	at io.mockk.shadowed.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:320)
	at io.mockk.shadowed.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:306)
	at io.mockk.proxy.MockKInstrumentation.<init>(MockKInstrumentation.java:47)
	at io.mockk.proxy.MockKInstrumentation.init(MockKInstrumentation.java:43)
	at io.mockk.impl.JvmMockKGateway.<clinit>(JvmMockKGateway.kt:112)
	... 44 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.mockk.shadowed.bytebuddy.agent.Attacher.install(Attacher.java:77)
	at io.mockk.shadowed.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:373)
	... 50 more
Caused by: java.lang.UnsatisfiedLinkError: Native Library /usr/java/jdk1.8.0_111/jre/lib/amd64/libattach.so already loaded in another classloader
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1907)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1122)
	at sun.tools.attach.LinuxVirtualMachine.<clinit>(LinuxVirtualMachine.java:342)
	at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
	at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)

This is on a Linux CI server with Java 8. I use both mockito and mockito-kotlin and now (trying) to use mockk. It does work locally on Mac OS with Java 8

from mockk.

patrickcousins avatar patrickcousins commented on May 15, 2024

That fixed it for me @oleksiyp ! Thank you!

from mockk.

oleksiyp avatar oleksiyp commented on May 15, 2024

Version 1.6.3 released. It includes changes on bytebuddy shadowing. @binkley please check if it resolves your issue and close the ticket

from mockk.

oleksiyp avatar oleksiyp commented on May 15, 2024

No activity here. Seems like resolved

from mockk.

binkley avatar binkley commented on May 15, 2024

Sorry for slow reply. I pushed a working test with both mockk and mockito-kotlin in the same test class. It works!

from mockk.

oleksiyp avatar oleksiyp commented on May 15, 2024

Great! Thank you very much

from mockk.

geosmart avatar geosmart commented on May 15, 2024
Error Message
java.lang.ExceptionInInitializerError
Stacktrace
java.lang.ExceptionInInitializerError
	at cn.com.xxx.xx.yy.web.aspect.rbac.FileAuthorityTest$Companion.setup(FileAuthorityTest.kt:88)
	at cn.com.xxx.xx.yy.web.aspect.rbac.FileAuthorityTest.setup(FileAuthorityTest.kt)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	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.RunBefores.evaluate(RunBefores.java:24)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@5ad8e3ce
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:613)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:586)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:538)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:515)
	at io.mockk.proxy.jvm.JvmMockKAgentFactory.initInstrumentation(JvmMockKAgentFactory.kt:127)
	at io.mockk.proxy.jvm.JvmMockKAgentFactory.init(JvmMockKAgentFactory.kt:33)
	at io.mockk.impl.JvmMockKGateway.<init>(JvmMockKGateway.kt:46)
	at io.mockk.impl.JvmMockKGateway.<clinit>(JvmMockKGateway.kt:173)
	... 44 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.bytebuddy.agent.Attacher.install(Attacher.java:106)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:608)
	... 51 more
Caused by: java.lang.UnsatisfiedLinkError: Native Library /usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/libattach.so already loaded in another classloader
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1900)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1838)
	at java.lang.Runtime.loadLibrary0(Runtime.java:871)
	at java.lang.System.loadLibrary(System.java:1124)
	at sun.tools.attach.LinuxVirtualMachine.<clinit>(LinuxVirtualMachine.java:342)
	at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
	at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
	... 57 more

Native Library /usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/libattach.so already loaded in another classloader

still exist in "io.mockk:mockk:1.11.0"

env: linux,java8

from mockk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.