Hi,
JaCoCo needs to instrument the class files to collect coverage
information. If you want to enable/disable code coverage within a
running JVM this means to re-instrument classes which are already
loaded. Due to the way how JaCoCo instrumentation works (adding a new
static member and a method) this is not possible with the current
limitations of JVMs that re-transformation must not add or remove members.
I haven't tried an alternative implementation yet, but my guess is that
every implementation that can not rely on local state will come with a
very bad performance impact, as every single method call would require
communication with the JaCoCo runtime.
Cheers,
-marc