Skip to main content
Last updated September 21, 2013 17:55, by johnoliver
Feedicon  

How to make Jacoco work with Java 8

Preliminary code coverage numbers from this method can be found at:

http://sticky.uwcs.co.uk/ojdk/coveragereport

These are known to be inaccurate, I believe this is due to the jacoco agent not being able to re-transform classes that have already been loaded at the time the agent is attached, in the case of JTREG testing this may include the class under test.

Steps used to produce this report:

  1. Check out java 8 branch of the jacoco source at:
  2. Build and install
  3. Build JDK
  4. Modify jdk/test/Makefile to add the jacoco agent to the build class path. I added the following
 JTREG_JACOCO_OPTION = -vmoption:-javaagent:/home/joliver/.m2/repository/org/jacoco/org.jacoco.agent/0.6.4-SNAPSHOT/org.jacoco.agent-0.6.4-SNAPSHOT-runtime.jar=destfile=/tmp/jacoco.exec,excludes="",exclclassloader="",includes="*"
 JTREG_TEST_OPTIONS += $(JTREG_JACOCO_OPTION)
  1. Run make inside jdk/test
  2. This will produce a coverage jacoco.exec at /tmp/jacoco.exec
  3. Run a Jacoco report generator over the jacoco.exec file. Example report generator at:
 https://github.com/johnoliver/jacoco-report-generator

Can be run with:

 java jo.jdk.jacoco_test.ReportGenerator -d "/tmp/jacoco.exec" -c "/home/joliver/workspace/jdk8/build/linux-x86_64-normal-server-release/jdk/classes" -s "/home/joliver/workspace/jdk8/jdk/src/share/classes" -o "/tmp/coveragereport"

I am looking an alternative method of building which sofar is having issues. This general approach is:

  1. Build JDK
  2. Extract rt.jar of jdk under test
  3. Statically instrument classes with jacoco offline mode
  4. Repackage up into rt.jar
  5. Run tests


 
 
Close
loading
Please Confirm
Close