Thank your for your reply~ Recently I have been studied the original code.  
I read the page " 
https://www.jacoco.org/jacoco/trunk/doc/implementation.html"; , but  I 
noticed the most tricky part is not shown  in "Coverage RunTime Dependency" 
section. I still confused about the equals method. 
*So Question 1 is: When the code "access.equals(args)"  is executed, what 
happenned on earth?Could you explain it in detail please?*

//begin








*Object access = ... // Retrieve instanceObject[] args = new 
Object[3];args[0] = Long.valueOf(8060044182221863588); // class idargs[1] = 
"com/example/MyClass"; // class nameargs[2] = Integer.valueOf(24); // probe 
countaccess.equals(args);boolean[] probes = (boolean[]) args[0];*
//end

 By the way, I found there is an equals method overridden in class  
RuntimeData, but  I  couldn't find the place it called. I don't think it 
has something to do with the call  "*access.equals(args);"  , *because  
 the variable "access" is not an instance fo RunTimeData.
*So Question 2 is : Where and When will the RunTimeData.equals() method be 
called?*

Regards*,*

在2020年9月15日星期二 UTC+8 上午3:43:03<Marc R. Hoffmann> 写道:

> Hi,
>
> we use the equals method as an “API” to the JaCoCo runtime. See “Coverage 
> Runtime Dependency” here: 
> https://www.jacoco.org/jacoco/trunk/doc/implementation.html
>
> Regards,
> -marc
>
>
>
>
> On 14. Sep 2020, at 16:22, zhen da <[email protected]> wrote:
>
> https://www.jacoco.org/jacoco/trunk/doc/implementation.html
> I found the error occured because I deleted the codeline 
> "UnknownError.$jacocoAccess.equals(arrobject);", but what happend behind 
> the equals method?
> 在2020年9月14日星期一 UTC+8 下午10:05:54<zhen da> 写道:
>
>> hey,guys~
>>
>>    I checked the generated probe code,which is the $jacocoInit$() method. 
>> private static /* synthetic */ boolean[] $jacocoInit() {
>>             boolean[] arrbl = $jacocoData;
>>             if ($jacocoData == null) {
>>                 Object[] arrobject = new Object[]{-4939888610684879937L, 
>> "org/jacoco/examples/CoreTutorial$MemoryClassLoader", 6};
>>                 UnknownError.$jacocoAccess.equals(arrobject);
>>                 arrbl = $jacocoData = (boolean[])arrobject[0];
>>             }
>>             return arrbl;
>>         }
>>
>> When I saw the code   
>> arrbl = $jacocoData = (boolean[])arrobject[0];
>>
>> I was really confused.Why a variable of type "long" can be cast to a 
>> boolean array type? So I did a test:
>>
>> public class TestJacocoInit {
>>     private static transient /* synthetic */ boolean[] $jacocoData;
>>
>>     public static /* synthetic */ boolean[] $jacocoInit() {
>>         boolean[] arrbl = $jacocoData;
>>         if ($jacocoData == null) {
>>             Object[] arrobject = new Object[]{4824536285859479710L, 
>> "org/jacoco/examples/CoreTutorial$TestTarget", 6};
>>             //UnknownError.$jacocoAccess.equals(arrobject);
>>             arrbl = $jacocoData = (boolean[])arrobject[0];
>>         }
>>         return arrbl;
>>     }
>>
>>     public static void main(String[] args){
>>         $jacocoInit();
>>     }
>> }
>>
>>
>> The program occured error when executed:
>>
>> objc[25273]: Class JavaLaunchHelper is implemented in both 
>> /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java 
>> (0x10bd1e4c0) and 
>> /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/libinstrument.dylib
>>  
>> (0x10ddc04e0). One of the two will be used. Which one is undefined.
>> Connected to the target VM, address: '127.0.0.1:54961', transport: 
>> 'socket'
>> Exception in thread "main" java.lang.ClassCastException: java.lang.Long 
>> cannot be cast to [Z
>> at org.jacoco.examples.TestJacocoInit.$jacocoInit(TestJacocoInit.java:16)
>> at org.jacoco.examples.TestJacocoInit.main(TestJacocoInit.java:22)
>> Disconnected from the target VM, address: '127.0.0.1:54961', transport: 
>> 'socket'
>>
>>
>>
>> Can somebody explain these jacoco generated codes?
>>
>>
>> Thanks~
>>
>>
> -- 
> 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/2bceb343-d07c-4905-b8b8-71ff901acd93n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/2bceb343-d07c-4905-b8b8-71ff901acd93n%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/4a649ad1-188a-4164-8657-75f9bd23e1b5n%40googlegroups.com.

Reply via email to