How to feed EclEmma (w Jacoco) with externally collected data

308 views
Skip to first unread message

Aslak Knutsen

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

In Arquillian we collect coverage data from remote jvm's using Jacoco. When used in combination with the Maven Jacoco plugin we simply append the remote data to the target/jacoco.exec file and the Report plugin is happy to report on it. 

How can we get the same integration with the Eclipse IDE plugin?
Is there a alternative file location to use?

Aslak Knutsen

unread,
Nov 24, 2012, 6:47:22 PM11/24/12
to jac...@googlegroups.com
... one hacky options ...

Lookup the UUID ExecutionDataAccess field added by the MemoryExecutionDataSource from the javaagent and append the remote data:

Field f = UUID.class.getDeclaredField("$jacocoAccess");
Object executor = f.get(null);
Method m = executor.getClass().getDeclaredMethod("getExecutionData", new Class[]{Object[].class});
for(ExecutionData data : dataStore.getContents()) {
   m.setAccessible(true);
   Object[] probeData = new Object[] {data.getId(), data.getName(), data.getData().length};
   m.invoke(executor, new Object[] {probeData});
   boolean[] resultData = (boolean[])probeData[0];
   for(int i = 0; i < data.getData().length; i++) {
  if(!resultData[i]) {
  resultData[i] = data.getData()[i];
  }
   }
}

Any cleaner way? :)

-aslak-

Aslak Knutsen

unread,
Nov 24, 2012, 6:48:28 PM11/24/12
to jac...@googlegroups.com
oops.. I mean ModifiedSystemClassRuntime, not MemoryExecutionDataSource.

Marc R. Hoffmann

unread,
Nov 25, 2012, 4:06:15 AM11/25/12
to jac...@googlegroups.com
Hi,

by design the JaCoCo agent should not be visible to the application
under test. That's why there are only hacky options. Another one would
be to look for a private static field $jacocoData in the application
classes (added by instrumentation).

Best regards,
-marc
> --
>

Marc R. Hoffmann

unread,
Nov 26, 2012, 2:20:26 PM11/26/12
to jac...@googlegroups.com
Hi,

via "File -> Import" you can import external *.exec files which results
in a separate sessions. Multiple sessions can merged into a single one
in the coverage view.

All this is based on public APIs of the eclemma.core plug-in.

Best regards,
-marc
> --
>
>


Aslak Knutsen

unread,
Nov 26, 2012, 3:20:02 PM11/26/12
to jac...@googlegroups.com
yea, but for that I need access to the Eclipse JVM. I'm only running in the JUnit JVM.

I'm using the UUID ExecutionDataAccess hack at the moment. While it's a hack it seems to work quite nicely with both Maven and Eclipse. 

-aslak-

Marc R. Hoffmann

unread,
Nov 26, 2012, 3:30:20 PM11/26/12
to jac...@googlegroups.com
Ok, I see. So JVM A (under control of EclEmma) spawns JVM B (also under
code coverage) and collects execution data from B. Correct?

I don't think this is currently possible.

BTW, EclEmma does not work with *.exec files. It uses opens a socket
server for every launch and configured the agent in tcpclient mode.

Best regards,
-marc
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages