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 <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 > <http://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 > <http://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] > <mailto:[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/1C4F6557-6ACD-4CB8-A2A5-1124B6413746%40mountainminds.com.
