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 jacoco+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/c2504303-16a3-4536-b87e-50eca8b9cf97o%40googlegroups.com.