Hi,

On Monday, November 5, 2018 at 11:00:55 PM UTC+1, [email protected] wrote:
>
> Hello Team,
>
> I am using the offline instrumentation of classes. I have couple of 
> queries. Please help to resolve them
>
> 1. I have my pre-instrumented classes in folder "instrumented". Now, While 
> running java application I am using below command :
> java -cp .:instrumented:jacoco-0.8.1/lib/jacocoagent.jar Main.class server 
> config.yml
>
> How can I give VM arguments to configure Jacoco properties such as output, 
> address and port ?
>

This is described in documentation on page about offline instrumentation - 
https://www.jacoco.org/jacoco/trunk/doc/offline.html 
 

> I have tried -Djacoco-agent.output=tcpserver,address=localhost,port=6301 
> and also
>

This is incorrect - not only "output", but all options should be passed to 
JVM with prefix "jacoco-agent."
 

> -Djacoco-agent.output=tcpserver -Djacoco-agent.address=localhost 
> -Djacoco-agent.port=6301
>

This seems correct, however
 

> But while dumping the coverage using jacococli.jar it gives error:
> Connection to 127.0.0.1(6301) refused.
>

Note that above documentation page says

"The first instrumented class loaded will trigger the initialization of the 
JaCoCo runtime. If no instrumented class is loaded the JaCoCo runtime will 
not get started at all."

This might explain why server can't be reached in case of class path 
specified as

".:instrumented:jacoco-0.8.1/lib/jacocoagent.jar"

if directory "." contains non-instrumented original classes, then they will 
be loaded first and instrumented classes will never be loaded - please 
refer to how class path and loading of classes work.

The best is to completely replace original classes by instrumented.
 

> 2. Also what is class path also has same application jar. 
>
 

> So there are my instrumented classes and also classes that are 
> non-instrumented in jar
>

See above 
 

> without which my Main class gives NoClassFound Error. Placing instrumented 
> class in class path
>
along with Jacoco agent jar will capture the coverage ?
>

As stated in several places in documentation, including description of 
offline instrumentation:

"the preferred way for code coverage analysis with JaCoCo is on-the-fly 
instrumentation with the JaCoCo agent"

exactly because

"This simplifies code coverage analysis a lot as no pre-instrumentation and 
classpath tweaking is required."

so have you considered usage of

https://www.jacoco.org/jacoco/trunk/doc/agent.html

as

java -javaagent:jacoco-0.8.1/lib/jacocoagent.jar=output=tcpserver -cp . 
Main.class server config.yml

?

-- 
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/9b308f6f-1432-4461-9c2f-7271dae3f018%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to