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

Mocking java.io.File constructor throws StackOverflowError #603

Open
3 tasks done
anggrayudi opened this issue Apr 19, 2021 · 4 comments
Open
3 tasks done

Mocking java.io.File constructor throws StackOverflowError #603

anggrayudi opened this issue Apr 19, 2021 · 4 comments

Comments

@anggrayudi
Copy link

anggrayudi commented Apr 19, 2021

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

Expected Behavior

Can mock java.io.File constructor.

Current Behavior

Throws StackOverflowError

Steps to Reproduce

Just run the following snippets:

    @Test
    fun abc() {
        mockkConstructor(File::class)
    }

Context

  • MockK version: 1.11.0
  • OS: MacOS Big Sur 11.2.3
  • Kotlin version: 1.4.32
  • JDK version: 1.8.0_262
  • JUnit version: 5.7.1
  • Type of test: unit test

Stack trace

Exception in thread "main" java.lang.StackOverflowError
	at sun.misc.URLClassPath.getResource(URLClassPath.java:247)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:405)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at io.mockk.impl.instantiation.JvmConstructorMockFactory$ConstructorInvocationHandler.invocation(JvmConstructorMockFactory.kt:171)
	at io.mockk.proxy.jvm.advice.BaseAdvice.constructorDone(BaseAdvice.kt:33)
	at java.io.File.<init>(File.java:376)
	at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1374)
	at sun.misc.URLClassPath.getResource(URLClassPath.java:249)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at io.mockk.impl.instantiation.JvmConstructorMockFactory$ConstructorInvocationHandler.invocation(JvmConstructorMockFactory.kt:171)
	at io.mockk.proxy.jvm.advice.BaseAdvice.constructorDone(BaseAdvice.kt:33)
@stale
Copy link

stale bot commented Jun 18, 2021

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 ask to put an important label.

@stale stale bot added the stale label Jun 18, 2021
@anggrayudi
Copy link
Author

Stalebot, please unstale it.

@stale stale bot removed the stale label Jun 19, 2021
@stale
Copy link

stale bot commented Aug 21, 2021

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 ask to put an important label.

@stale stale bot added the stale label Aug 21, 2021
@anggrayudi
Copy link
Author

Stalebot, please unstale it.

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

2 participants