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

Bug: MockK cannot be used in a project with module-info.java #296

Open
mpe85 opened this issue May 9, 2019 · 10 comments
Open

Bug: MockK cannot be used in a project with module-info.java #296

mpe85 opened this issue May 9, 2019 · 10 comments

Comments

@mpe85
Copy link

mpe85 commented May 9, 2019

Prerequisites

  • [ X ] I am running the latest version
  • [ X ] I checked the documentation and found no answer
  • [ X ] I checked to make sure that this issue has not already been filed

Expected Behavior

Mockk should work when using Java 9 modules

Current Behavior

The java compiler fails (see error message below)

Failure Information (for bugs)

The reason why it does not work is that there are two artifacts (mockk-1.9.3.jar and mockk-dsl-jvm-1.9.3.jar) that have classes in the same package (io.mockk).
The java platform module system (JPMS) creates two automatic modules from these jars (named mockk and mockk-dsl-jvm). The problem is that the JPMS does not allow two modules to export the same package.
Putting the classes in different packages would solve this issue.
Mind there may be more jars (like mockk-common) that have classes in this package.

Steps to Reproduce

  1. Add io.mockk:mockk:1.9.3 to dependencies of a JPMS project
  2. Run any JUnit 5 test

Context

  • MockK version: 1.9.3
  • OS: Win 10
  • Kotlin version: 1.3.31
  • JDK version: 11.0.3
  • JUnit version: 5.4.2
  • Type of test: Unit test

Failure Logs

java.lang.module.ResolutionException: Modules mockk and mockk.dsl.jvm export package io.mockk to module kotlin.stdlib.common
java.lang.module.ResolutionException: Modules mockk.dsl.jvm and mockk export package io.mockk to module org.junit.jupiter.engine

@oleksiyp
Copy link
Collaborator

oleksiyp commented May 9, 2019

Thank you

@mpe85
Copy link
Author

mpe85 commented May 9, 2019

You're welcome.

As a workaround I will run my tests on classpath instead of modulepath.

@mpe85
Copy link
Author

mpe85 commented May 22, 2019

Do you plan to fix this?

@oleksiyp
Copy link
Collaborator

I plan to fix if it is possible not to change public interface, but currently on my main workplace there is a lot of work, so it will happen not now. I dont want to promise anything. My hope as well that some contributors will finally appear while I am not doing this maintenance job.

@mpe85
Copy link
Author

mpe85 commented May 23, 2019

OK, thanks for the information

@stale
Copy link

stale bot commented Jul 23, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are sure that this issue is important and should not be marked as stale just put an important tag.

@stale stale bot added the stale label Jul 23, 2019
@stale stale bot closed this as completed Jul 30, 2019
@oleksiyp oleksiyp changed the title Mockk cannot be used in a project with module-info.java Bug: MockK cannot be used in a project with module-info.java Nov 2, 2019
@Patresss
Copy link

Patresss commented Jun 6, 2020

Any news here?

@ianbrandt
Copy link

I just hit this as well. Should this issue be reopened?

@Raibaz Raibaz reopened this Feb 19, 2021
@ennioVisco
Copy link

Still relevant and problematic for Java modules adoption.

@WIPARNAB
Copy link

Process 'Gradle Test Executor 2' finished with non-zero exit value 1
org.gradle.process.internal.ExecException: Process 'Gradle Test Executor 2' finished with non-zero exit value 1
	at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:414)
	at org.gradle.process.internal.worker.DefaultWorkerProcess.onProcessStop(DefaultWorkerProcess.java:141)
	at org.gradle.process.internal.worker.DefaultWorkerProcess.access$000(DefaultWorkerProcess.java:42)
	at org.gradle.process.internal.worker.DefaultWorkerProcess$1.executionFinished(DefaultWorkerProcess.java:94)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:43)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:245)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:157)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy1/jdk.proxy1.$Proxy168.executionFinished(Unknown Source)
	at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:221)
	at org.gradle.process.internal.DefaultExecHandle.finished(DefaultExecHandle.java:354)
	at org.gradle.process.internal.ExecHandleRunner.completed(ExecHandleRunner.java:110)
	at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:84)
	at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
	at java.base/java.lang.Thread.run(Thread.java:840)
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules mockk.dsl.jvm and mockk.jvm export package io.mockk to module kotlin.test.junit

io.mockk:mockk - 1.13.10
Kotlin - 1.6.22
Zulu JDK+JFX - 17.0.10

Any update on this fix?

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

No branches or pull requests

7 participants