Filter out a given parameter in jacoco agent

21 views
Skip to first unread message

Shehan Dhaleesha

unread,
Oct 30, 2019, 2:29:53 AM10/30/19
to JaCoCo and EclEmma Users
Hi,

It's me (ballerina guy) again. Hope you already remember me. So this time I need to filter out some method arguments from jacoco agent before generating the jacoco.exec file. So this is a sample javap -c output of a compiled ballerina program.

Screenshot from 2019-10-30 11-52-04.png

As you can see there is a argument (org.ballerinalang.jvm.scheduling.Strand) that is passed to the main method in the given program. So I need to filter that out from the jacoco.exec file which means I don't need to include that argument's effect to the program's coverage report. So What I've tried is introducing a filter to the jacoco core/internal/analysis/filter. But I don't know how to filter them out. Could you please help me on this? I really appreciate your contribution as I'm stucked with this.

java compiled file is attached here for more information.


Regards,

Shehan.

main.class

Marc Hoffmann

unread,
Oct 30, 2019, 4:32:41 AM10/30/19
to jac...@googlegroups.com

Hi Shehan,

sure, I remember. Funny ballerina bytecode helped us to fix two corner cases ;)

JaCoCo only reports byte code instructions. Method definitions like parameters are not executable as such and not reported. I guess you want to filter certain operations which happens on the Strand instance. What the filters do they look for certain bytecode patterns and filter sequences of byte codes when the pattern matches. Some hints:

  1. You can study existing filter implementations.
  2. New filters needs to be registered here.
  3. Filtering is pure internal, JaCoCo has no API to add new filters. So you will need to implement a new filter in a fork.
  4. I recommend to add a integration test for Ballerina first. You can study our exiting tests for Scala, Kotlin or Groovy as starting point.

Cheers,
-marc

--
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 jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/5ce07a65-b138-4345-8b61-889821af74de%40googlegroups.com.


main.class
Screenshot from 2019-10-30 11-52-04.png

Shehan Dhaleesha

unread,
Oct 30, 2019, 10:32:52 AM10/30/19
to JaCoCo and EclEmma Users
Hi Marc,
Thanks for the details and I'll follow the steps. Hope it will work.. :D
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages