Skip to content

Commit

Permalink
Patch: update instrumentation order to fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
k-melnik authored and fmeum committed Apr 21, 2023
1 parent 8888167 commit f24a8d8
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,9 @@ class RuntimeInstrumentor(
}
return ClassInstrumentor(internalClassName, bytecode).run {
if (fullInstrumentation) {
// Hook instrumentation must be performed after data flow tracing as the injected
// bytecode would trigger the GEP callbacks for byte[]. Coverage instrumentation
// must be performed after hook instrumentation as the injected bytecode would
// trigger the GEP callbacks for ByteBuffer.
traceDataFlow(instrumentationTypes)
hooks(includedHooks + customHooks, classWithHooksEnabledField)
// Coverage instrumentation must be performed before any other code updates
// or there will be additional coverage points injected if there are any call is inserted
// and JaCoCo will produce a broken coverage report.
coverageIdSynchronizer.withIdForClass(internalClassName) { firstId ->
coverage(firstId).also { actualNumEdgeIds ->
CoverageRecorder.recordInstrumentedClass(
Expand All @@ -230,6 +227,10 @@ class RuntimeInstrumentor(
)
}
}
// Hook instrumentation must be performed after data flow tracing as the injected
// bytecode would trigger the GEP callbacks for byte[].
traceDataFlow(instrumentationTypes)
hooks(includedHooks + customHooks, classWithHooksEnabledField)
} else {
hooks(customHooks, classWithHooksEnabledField)
}
Expand Down

0 comments on commit f24a8d8

Please sign in to comment.