Safe way to detect running in Coverage mode

77 views
Skip to first unread message

Aslak Knutsen

unread,
Nov 24, 2012, 9:19:13 AM11/24/12
to jac...@googlegroups.com
Heya

In the Arquillian project we have a Jacoco extension that auto enables remote jvm coverage data. The extension will automatically enable recording coverage data when the extension is on classpath. I was wondering about the possibility of changing this to only enable remote recording if the client jvm is running in 'coverage mode'. As it's not really useful to record the remote coverage data if no plugin (IDE or Build) is around to record the client JVM and report on it. 

Is there a safe API way to detect if Jacoco is active/running/has instrumented the classes?

Evgeny Mandrikov

unread,
Dec 6, 2012, 7:57:42 AM12/6/12
to jac...@googlegroups.com
Hi,

Short answer is probably no - there is no such API.

rupert....@gmail.com

unread,
Nov 11, 2013, 4:53:05 AM11/11/13
to jac...@googlegroups.com
there was a ticket on jboss developer studio suggesting it would be nice to enable/disable the agent programmatically:
https://issues.jboss.org/browse/JBDS-2017

Marc R. Hoffmann

unread,
Nov 11, 2013, 6:49:54 AM11/11/13
to jac...@googlegroups.com
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
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages