Hi,

it’s not only about the VM parameter, you also need the jacocoagent.jar file 
available in the docker container. This also holds true if you want to attach 
dynamically (which comes with other challenges when the JVM is running in a 
docker container).

The most robust solution will probably be if you create a docker image which 
includes the JaCoCo agent and has an option in its start script to enable the 
agent.

Cheers,
-marc

> On 24. Nov 2022, at 03:41, Jun Fu <[email protected]> wrote:
> 
> Hi,
> 
> My case is,  I use a linux virtual machine with a docker installed. My 
> springboot project is deployed in the docker and is running. I want to run 
> local interface tests and get code coverage data of the springboot project.
> As far as I know, I can use  
> '-javaagent:[yourpath/]jacocoagent.jar=[option1]=[value1],[option2]=[value2]' 
>  to inject jacocoagent.jar into this docker,  but I need to modify the 
> startup script of the docker container and
> restart. Because this docker container will reset all additional actions 
> every time it is updated and this springboot project interface will be 
> called,so in order to reduce impact,I want to attach a running jvm without
> restarting.
> 
> I'm not sure I have described the case clearly?
> 
> I learned that the agent.jar can be dynamically attached to a running java 
> process through javaagent (agentmain),  that is,  the dynamic instrument 
> after the JVM starts. When the class has been loaded,  it could  use
> Instrumentation#retransformClasses to retransform the corresponding class. 
> But it seems that jacoco does not support this now, so I don't know how to 
> implement it.
> 
> Thanks.
> 
> 在2022年11月23日星期三 UTC+8 21:47:07<Marc R. Hoffmann> 写道:
> Hi,
> 
> this is not supported and there are no plans to do so. Depending on the 
> instrumentation strategy the schema of the class files needs to be changed, 
> which is not supported by the JVM,
> 
> Out of curiosity, what is your use case for this?
> 
> Regards,
> -marc 
> 
> 
>> On 23. Nov 2022, at 12:24, Jun Fu <[email protected] 
>> <applewebdata://2D94740A-BFBE-4522-A2DF-FCF9B1C92790>> wrote:
>> 
> 
>> Hi guys,
>> Is it possible to dynamically inject Jacocoagent.jar into an already running 
>> jvm without restarting?such as injecting through agentmain?
>> 
> 
>> -- 
>> 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://2D94740A-BFBE-4522-A2DF-FCF9B1C92790>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/a6399ba7-2a85-4eaa-aebc-79b0a8c50437n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/a6399ba7-2a85-4eaa-aebc-79b0a8c50437n%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/8ff53f60-1835-422a-b11e-2a5e34f4f3f2n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/8ff53f60-1835-422a-b11e-2a5e34f4f3f2n%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/826124F8-6105-4B07-A373-F8D658BFAFEA%40mountainminds.com.

Reply via email to