> Is it possible to recover it without relying on the class files?

No, JaCoCo is based on class files.

> E.g. if I only have the source code, theoretically, I know where the branches 
> are (statically analyzing and identifying IFs, Switches, Exceptions, ...), 
> then I also thereotically should know where the probes have been inserted 
> right?


You can compile these class files given that you use the exact same build 
chain. Please see https://www.jacoco.org/jacoco/trunk/doc/classids.html 
<https://www.jacoco.org/jacoco/trunk/doc/classids.html>

> JaCoCo tracks execution with so called probes. Probes are additional byte 
> code instructions inserted in the original class file which will note when 
> they are executed and report this to the JaCoCo runtime. This process is 
> called instrumentation. To keep the runtime overhead minimal, only a few 
> probes are inserted at "strategic" places. These probe positions are 
> determined by analyzing the control flow 
> <https://www.jacoco.org/jacoco/trunk/doc/flow.html> of all methods of a 
> class. As a result every instrumented class produces a list of n boolean 
> flags indicating whether the probe has been executed or not. A JaCoCo *.exec 
> file simply stores a boolean array per class id.
> 
> At analysis time, for example for report generation, the *.exec file is used 
> to get information about probe execution status. But as probes are stored in 
> a plain boolean array there is no information like corresponding methods or 
> lines. To retrieve this information we need the original class files and 
> perform the exact same control flow analysis than at instrumentation time. 
> Because this is a deterministic process we get the same probe positions. With 
> this information we can now interfere the execution status of every single 
> instruction and branch of a method. Using the debug information embedded in 
> the class files we can also calculate line coverage.
> 
> If we would use just slightly different classes at analysis time than at 
> runtime — e.g. different method ordering or additional branches — we would 
> end-up with different probes. For example the probe at index i would be in 
> method a() and not in method b(). Obviously this will create random coverage 
> results. 
> 


> On 10. Jul 2022, at 12:27, Tom G <[email protected]> wrote:
> 
> Thanks for the quick response :)
> Is it possible to recover it without relying on the class files?
> E.g. if I only have the source code, theoretically, I know where the branches 
> are (statically analyzing and identifying IFs, Switches, Exceptions, ...), 
> then I also thereotically should know where the probes have been inserted 
> right?
> 
> Marc R. Hoffmann schrieb am Sonntag, 10. Juli 2022 um 11:57:42 UTC+2:
> Hi Tom,
> 
> as “simple” as it is described here: 
> https://www.jacoco.org/jacoco/trunk/doc/flow.html 
> <https://www.jacoco.org/jacoco/trunk/doc/flow.html>
> 
> In short: You need the underlying class files to interpret the probes. This 
> is exactly what the JaCoCo analyzer does.
> 
> Regards,
> -marc
> 
> 
>> On 10. Jul 2022, at 11:53, Tom G <[email protected] 
>> <applewebdata://AE55F026-838F-451C-BD13-4CF9BA4B93B4>> wrote:
>> 
> 
>> Hi,
>> if I have a probe boolean array and the name of the class. Is there some 
>> simple manual way to map a hit probe to the corresponding source line?
>> 
>> Regards,
>> Tom
>> 
> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <applewebdata://AE55F026-838F-451C-BD13-4CF9BA4B93B4>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/bf8afb15-7adf-41f5-a854-5c92346c7d43n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/bf8afb15-7adf-41f5-a854-5c92346c7d43n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/8b9c6f58-51d0-417d-9ba6-6f8ce8dfc0b6n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/8b9c6f58-51d0-417d-9ba6-6f8ce8dfc0b6n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/54C53196-A572-4DBE-A9EA-44D94E01B462%40mountainminds.com.

Reply via email to