郑泽明
郑泽明

Reputation: 1

mockk error:java.lang.VerifyError: Constructor must call super() or this() before return

When I tried to upgrade the targetsdkversion to 35, the unit test mockk had problems, and the following error was reported when executing “private val context = mockk()”

Nov 08, 2024 4:13:21 PM io.mockk.impl.log.JULLogger warn
WARNING: Failed to transform class android/content/Context
java.lang.VerifyError: Constructor must call super() or this() before return
Exception Details:
  Location:
    android/content/Context.<init>()V @21: return
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: 1304 f2c0 04f4 4dbb 036b 5913 036d b703
    0000010: 702c 0304 54b1                         

    at java.base/java.lang.Class.getDeclaredFields0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
    at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
    at net.bytebuddy.description.type.TypeDescription$ForLoadedType.getDeclaredFields(TypeDescription.java:8937)
    at net.bytebuddy.dynamic.scaffold.InstrumentedType$Factory$Default$1.represent(InstrumentedType.java:436)
    at net.bytebuddy.ByteBuddy.redefine(ByteBuddy.java:886)
    at net.bytebuddy.ByteBuddy.redefine(ByteBuddy.java:861)
    at io.mockk.proxy.jvm.transformation.InliningClassTransformer.transform(InliningClassTransformer.kt:74)
    at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244)
    at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:541)
    at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
    at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:169)
    at io.mockk.proxy.jvm.transformation.JvmInlineInstrumentation.retransform(JvmInlineInstrumentation.kt:28)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1.invoke(RetransformInlineInstrumentation.kt:19)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1.invoke(RetransformInlineInstrumentation.kt:16)
    at io.mockk.proxy.common.transformation.ClassTransformationSpecMap.applyTransformation(ClassTransformationSpecMap.kt:41)
    at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation.execute(RetransformInlineInstrumentation.kt:16)
    at io.mockk.proxy.jvm.ProxyMaker.inline(ProxyMaker.kt:90)
    at io.mockk.proxy.jvm.ProxyMaker.proxy(ProxyMaker.kt:34)
    at io.mockk.impl.instantiation.JvmMockFactory.newProxy(JvmMockFactory.kt:34)
    at io.mockk.impl.instantiation.AbstractMockFactory.newProxy$default(AbstractMockFactory.kt:24)
    at io.mockk.impl.instantiation.AbstractMockFactory.mockk(AbstractMockFactory.kt:59)


I try to update mockk version to lasted 1.13.13,but it do not work

Hope to get help, thanks

Upvotes: 0

Views: 19

Answers (0)

Related Questions