JaCoCo inserts custom objects into all objects. Reflection finds these objects

51 views
Skip to first unread message

tylerbth...@gmail.com

unread,
Feb 2, 2019, 2:15:16 PM2/2/19
to JaCoCo and EclEmma Users
I've written a pretty printing library https://github.com/snowe2010/pretty-print,
and am trying to get code cov for it. As soon as I add jacoco, all my tests fail because reflection now finds extra `$jacocoData = boolean[]()` objects pretty much everywhere.

Is there any way around this, or will I just not be able to use jacoco?

Evgeny Mandrikov

unread,
Feb 3, 2019, 6:32:54 PM2/3/19
to JaCoCo and EclEmma Users
Please read documentation, this is described in FAQ ( https://www.jacoco.org/jacoco/trunk/doc/faq.html ) :

My code uses reflection. Why does it fail when I execute it with JaCoCo?

To collect execution data JaCoCo instruments the classes under test which adds two members to the classes: A private static field $jacocoData and a private static method $jacocoInit(). Both members are marked as synthetic.

Please change your code to ignore synthetic members. This is a good practice anyways as also the Java compiler creates synthetic members in certain situation.

tylerbth...@gmail.com

unread,
Feb 11, 2019, 10:58:01 PM2/11/19
to JaCoCo and EclEmma Users
Thank you Evgeny, I thought I had read the FAQ, but apparently not.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages