JetBrains / lincheck

Framework for testing concurrent data structures
Mozilla Public License 2.0
576 stars 33 forks source link

Coverage bytecode filter #335

Closed dmitrii-artuhov closed 3 months ago

dmitrii-artuhov commented 3 months ago

Notice

This PR also changes the way classes bytecode is restore to the initially loaded into Lincheck agent. Instead of redefineClasses(...) now retransformClasses(...) is used in order to avoid double-instrumentation by other attached agents (e.g. intellij-coverage agent was throwing ClassFormatError because of this problem).


Description

Relates to #254.

This PR adds a bytecode filter class, which "hides" bytecode generated by intellij-coverage agent (e.g. when using kover gradle plugin) from transformation that exist in Lincheck.

The bytecode tracking is implemented as state machine with 5 states (+ symbol designates the direction of an arrow):

                           INITIAL  +----------------------------------------
                       /            +                                       |
                     /                \                                     |
                   +                    +                                   |
          HITS_INIT           HITS_INIT_FIELD                               |
                    \                    /                                  |
                     +                  +                                   |
                        HITS_IN_LOCAL   -------------------------------------  
                         |         +                
                         +         |                
                      HITS_BEFORE_ASSIGN 

Short overview: