override fun getMethodConfiguration()

in jvm-agent/src/main/org/jetbrains/lincheck/jvm/agent/TransformationProfile.kt [342:403]


    override fun getMethodConfiguration(className: String, methodName: String, descriptor: String): TransformationConfiguration {
        val config = TransformationConfiguration()

        // NOTE: `shouldWrapInIgnoredSection` should be before `shouldNotInstrument`,
        //       otherwise we may incorrectly forget to add some ignored sections
        //       and start tracking events in unexpected places
        if (shouldWrapInIgnoredSection(className, methodName, descriptor)) {
            return config.apply {
                wrapInIgnoredSection = true
            }
        }
        if (shouldNotInstrument(className, methodName, descriptor)) {
            return config
        }

        // For `java.lang.Thread` class (and `ThreadContainer.start()` method),
        // we only apply `ThreadTransformer` and skip all other transformations
        if (isThreadClass(className) || isThreadContainerThreadStartMethod(className, methodName)) {
            return config.apply {
                trackAllThreadsOperations = true
            }
        }

        // Debugger implicitly evaluates `toString()` for variables rendering.
        // We need to ensure there are no `beforeEvents` calls inside `toString()`
        // to ensure the event numeration will remain the same.
        if (ideaPluginEnabled && isToStringMethod(methodName, descriptor)) {
            return config.apply {
                trackObjectCreations = true
            }
        }

        // Currently, constructors are treated in a special way to avoid problems
        // with `VerificationError` due to leaking this problem,
        // see: https://github.com/JetBrains/lincheck/issues/424
        if (methodName == "<init>") {
            return config.apply {
                trackObjectCreations = true
                trackAllSharedMemoryAccesses = true
            }
        }

        return config.apply {
            trackObjectCreations = true

            trackAllSharedMemoryAccesses = true

            trackMethodCalls = true
            trackInlineMethodCalls = true
            interceptMethodCallResults = true

            trackAllThreadsOperations = true
            trackAllSynchronizationOperations = true

            // In model checking mode we track all hash code calls in the instrumented code
            // and substitute them with a constant value.
            interceptIdentityHashCodes = true

            trackCoroutineSuspensions = true
            interceptCoroutineDelays = true
        }
    }