JetBrains / lincheck

Framework for testing concurrent data structures
Mozilla Public License 2.0
582 stars 34 forks source link

NoSuchFieldException for com.fasterxml.jackson.databind.ObjectMapper #77

Closed missingdays closed 3 years ago

missingdays commented 3 years ago

I have a class that I test containing com.fasterxml.jackson.databind.ObjectMapper to store json in the file. The test suite looks like this:

@StressCTest
@ModelCheckingCTest
class ATest : VerifierState() {
    private val a = A(Files.createTempFile("storage", ".json"))
...
}

class A(...) {
        private val objectMapper = ObjectMapper()
}

When running tests, I get the following error:

java.lang.ExceptionInInitializerError
    <here it points to the ObjectMapper line>
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
...
Caused by: java.lang.IllegalStateException: Cannot transform class com.fasterxml.jackson.databind.ser.BeanPropertyWriter
    at org.jetbrains.kotlinx.lincheck.TransformationClassLoader.loadClass(TransformationClassLoader.java:137)
    at com.fasterxml.jackson.databind.ObjectMapper.<clinit>(ObjectMapper.java:350)
    ... 43 more
Caused by: java.lang.IllegalStateException: Cannot transform class com.fasterxml.jackson.databind.ser.PropertyWriter
    at org.jetbrains.kotlinx.lincheck.TransformationClassLoader.loadClass(TransformationClassLoader.java:137)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:635)
...
Caused by: java.lang.NoSuchFieldException
    at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategyTransformerKt.findField(ManagedStrategyTransformer.kt:1422)
    at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategyTransformerKt.isFinalField(ManagedStrategyTransformer.kt:1407)
    ... 68 more
alefedor commented 3 years ago

@missingdays Hi! Thank you for your issue. There was a problem with transforming a class that inherited a field from an interface. Will be fixed in the next release.