Java Code Coverage Mechanics
summary
Deep dive into JaCoCo internals: instrumentation via a JVM agent that inserts boolean probe arrays (4–7 bytes per probe) into class files, validated across five JDK major versions and early builds, which surfaces real OpenJDK bugs (JaCoCo ranks among top five external reporters). Implementation uses the ASM library, synthetic static fields to cache probes (and a synthetic init accessor to avoid init-cycle NPEs), a Java 9 bytecode version trick, and an OSGi hack using a java.lang-held object and equals() to return probe arrays.
AI-written summary · about
chapters (17)
- 0:00Start
- 4:31Observer Effect
- 5:41Code Coverage
- 7:07JaCoCo works on class files only
- 8:31As easy as setting an arg for the JVM
- 9:17Java Byte Code Instrumentation
- 10:19Probe Strategies
- 11:29JaCoCo Validation Test Suite
- 12:27Tested on 5 major JDK versions
- 18:16Bytecode of Assertions
- 23:30Bridge Methods
- 24:06Methods in Enums
- 32:55Bad Cycles in JaCoCo
- 34:16Java Virtual Machine Specification
- 35:57Java Language Specification
- 40:31Runtime Access (Problem)
- 40:57Runtime Access (Solution)
related talks
46mJava, Code Coverage & Their Best Friend: Bytecode
56mJava 4..21, Kotlin, Code Coverage, bytecode: scandals, intrigues, investigations
46mKotlin, Java 4..18, Code Coverage and their best friend — bytecode: ...
39mBytecode Pattern Matching
50mCode Coverage Instrumentation
43mMutation Testing
54mJava's Hidden Gems
30mWriting Java agents for fun and not so much profit
