0

I want to run multiple jacoco javaagents on the same target with tcp ports. This causes an issue due to a naming conflict.

My thought is to rename the jacoco_agent.jar to jacoco2_agent.jar including all the class names.

I already tried jarjar, but that failed. Attaching the renamed jar raises an error. The ClassNotFoundException: org.jacoco.agent.rt.internal_3570298.PreMain occurs. Indicating that the naming did go wrong at some point.

  • You have to fix the class names in the `META-INF/MANIFEST.MF` as well. – Johannes Kuhn Nov 08 '22 at 15:12
  • Also, it is a bad idea to load the same agent twice - as they may interfere with each other, for example, instrumenting the instrumentation code of the other agent. – Johannes Kuhn Nov 08 '22 at 15:12
  • 2
    _"I want to run multiple jacoco javaagents on the same target"_ Why? Which problem are you trying to solve? – kriegaex Nov 09 '22 at 10:26
  • We use jacoco to guide our fuzzer. Our fuzzer is resetting the state of jacoco. However, in the end we want to get the full coverage. To obtain the full coverage we want to use the second jacoco agent. – Stefan van den Berg Nov 10 '22 at 09:25
  • 1
    Are you aware of the option to merge multiple JaCoCo files into one for a complete coverage report? You can do this with the JaCoCo Maven plugin (e.g. for multi-module projects) as well as manually. Just make sure that your fuzzer creates different files for each run, then merge them in the end. – kriegaex Nov 10 '22 at 11:17
  • That's a good option @kriegaex! I will try it as soon as I can. I will need to write code to store the exec files from the tcp-stream. – Stefan van den Berg Nov 11 '22 at 07:10
  • If the approach works for you, please let me know. Then I can covert the comment into an answer, which you then can accept in order to close the question. – kriegaex Nov 11 '22 at 08:08

1 Answers1

1

3 days ago Stefan wrote in a comment:

@kriegaex your solution worked. Thank you very much for your help.

Now that comment is gone, not sure why. Anyway, I am going to convert my comment into an answer:


Are you aware of the option to merge multiple JaCoCo files into one for a complete coverage report? You can do this with the JaCoCo Maven plugin (e.g. for multi-module projects) as well as manually. Just make sure that your fuzzer creates different files for each run, then merge them in the end.

kriegaex
  • 63,017
  • 15
  • 111
  • 202