ekstazi icon indicating copy to clipboard operation
ekstazi copied to clipboard

java.lang.NoSuchMethodError in org.ekstazi.monitor.ReflectionMonitor.hashCode

Open apri22 opened this issue 6 years ago • 3 comments

Im unit testing my android app with ekstazi gradle plugin i use kotlin, powermock, mockk

but test executed with this error

java.lang.NoSuchMethodError: org.ekstazi.monitor.ReflectionMonitor.hashCode(Ljava/lang/Class;)I 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.components.ReflectKotlinClass.hashCode(ReflectKotlinClass.kt:73) 16:26:15.099 [DEBUG] [TestEventLogger] at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:394) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:483) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.load.kotlin.AbstractBinaryClassAnnotationAndConstantLoader.findClassAndLoadMemberAnnotations(AbstractBinaryClassAnnotationAndConstantLoader.kt:143) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.load.kotlin.AbstractBinaryClassAnnotationAndConstantLoader.findClassAndLoadMemberAnnotations$default(AbstractBinaryClassAnnotationAndConstantLoader.kt:137) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.load.kotlin.AbstractBinaryClassAnnotationAndConstantLoader.loadCallableAnnotations(AbstractBinaryClassAnnotationAndConstantLoader.kt:101) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.serialization.deserialization.MemberDeserializer$getAnnotations$1.invoke(MemberDeserializer.kt:234) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.serialization.deserialization.MemberDeserializer$getAnnotations$1.invoke(MemberDeserializer.kt:33) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:323) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(LockBasedStorageManager.java:370) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.storage.StorageKt.getValue(storage.kt:39) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedAnnotationsWithPossibleTargets.getAnnotations(DeserializedAnnotations.kt) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedAnnotationsWithPossibleTargets.iterator(DeserializedAnnotations.kt:64) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.UtilKt.computeAnnotations(util.kt:190) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.KCallableImpl$annotations_$1.invoke(KCallableImpl.kt:41) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.KCallableImpl$annotations_$1.invoke(KCallableImpl.kt:28) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(ReflectProperties.java:93) 16:26:15.099 [DEBUG] [TestEventLogger] at kotlin.reflect.jvm.internal.KCallableImpl.getAnnotations(KCallableImpl.kt:43) 16:26:15.099 [DEBUG] [TestEventLogger] at io.mockk.impl.annotations.JvmMockInitializer.assignMockK(JvmMockInitializer.kt:288) 16:26:15.099 [DEBUG] [TestEventLogger] at io.mockk.impl.annotations.JvmMockInitializer.initMock(JvmMockInitializer.kt:36) 16:26:15.099 [DEBUG] [TestEventLogger] at io.mockk.impl.annotations.JvmMockInitializer.initAnnotatedMocks(JvmMockInitializer.kt:21) 16:26:15.099 [DEBUG] [TestEventLogger] at co.styletheory.android.testkit.unitTest.BaseUnitTest.setup(BaseUnitTest.kt:38) 16:26:15.099 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 16:26:15.099 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 16:26:15.099 [DEBUG] [TestEventLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 16:26:15.099 [DEBUG] [TestEventLogger] at java.lang.reflect.Method.invoke(Method.java:498) 16:26:15.099 [DEBUG] [TestEventLogger] at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:133) 16:26:15.099 [DEBUG] [TestEventLogger] at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:310) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:298) 16:26:15.099 [DEBUG] [TestEventLogger] at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87) 16:26:15.099 [DEBUG] [TestEventLogger] at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:218) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:160) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:134) 16:26:15.099 [DEBUG] [TestEventLogger] at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) 16:26:15.099 [DEBUG] [TestEventLogger] at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:136) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:121) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57) 16:26:15.099 [DEBUG] [TestEventLogger] at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59) 16:26:15.099 [DEBUG] [TestEventLogger] at org.ekstazi.junit.CoverageRunner.run(Unknown Source) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:106) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) 16:26:15.099 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 16:26:15.099 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 16:26:15.099 [DEBUG] [TestEventLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 16:26:15.099 [DEBUG] [TestEventLogger] at java.lang.reflect.Method.invoke(Method.java:498) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 16:26:15.099 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 16:26:15.100 [DEBUG] [TestEventLogger] at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:117) 16:26:15.100 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 16:26:15.100 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 16:26:15.100 [DEBUG] [TestEventLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 16:26:15.100 [DEBUG] [TestEventLogger] at java.lang.reflect.Method.invoke(Method.java:498) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) 16:26:15.100 [DEBUG] [TestEventLogger] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 16:26:15.100 [DEBUG] [TestEventLogger] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 16:26:15.100 [DEBUG] [TestEventLogger] at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 16:26:15.100 [DEBUG] [TestEventLogger] at java.lang.Thread.run(Thread.java:748)

apri22 avatar Nov 28 '18 09:11 apri22

Hi,

Thanks for the report. I assume that you are using Java 9+ in this experiment. If you use Java 8, this should not be happening. (I am not saying that the fix is to change a version of Java, but you can check if that helps you to avoid this issue.) My plan is to put source code for Ekstazi on GitHub this weekend, so you can modify code as you need. Next week I can help you debug this if you are still stuck, but I will need more info (java version, small reproducible example, etc.).

gliga avatar Nov 29 '18 17:11 gliga

hi gliga,

this my java version openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1ubuntu0.16.04.1-b13) OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

thanks for putting the source code.

here i created simple project to reproduce it https://github.com/apri22/SampleEkstazi

goto project directory then run gradle command mac os/linux ./gradlew testDebugUnitTest --info

apri22 avatar Nov 30 '18 15:11 apri22

@gliga or @apri22 any workaround about this? I also get this exact error on an Android Kotlin project of mine. It seems like the hashCode method is missing in ReflectionMonitor. I also tried the sample provided by @apri22 and tried to use the ekstazi 5.3.0 but still have the same problem. image

openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)

ehsan-salamati avatar Oct 13 '22 19:10 ehsan-salamati

Closing as we are not focusing on Java (and future work that explores Kotlin can address the issue if present at the time).

gliga avatar Feb 04 '24 21:02 gliga