Hi Mandrikov,

Thanks for the insights on this issue. I completely overlooked the existing 
jmockit bug. 

With the jmockit 1.46, the issue is gone. 

Thanks again

On Monday, May 6, 2019 at 4:33:15 PM UTC+5:30, Evgeny Mandrikov wrote:
>
>
>
> On Monday, May 6, 2019 at 12:38:42 PM UTC+2, [email protected] 
> <javascript:> wrote:
>>
>> I am having some issue with Mocking a class instrumented with jacoco. 
>> Problem:
>>  1. Junit Testcase Mocking a class with some static final fields.
>>  2. Class under Test is instrumented with jacoco-0.8.3
>>  3. Mocking is done using jmockit-1.44
>>  4. Using OpenJDK-11.0.1
>>  5. Test fails with **"Method <clinit> is not static in class file"**
>>  6. Test pass with JDK-1.8
>>
>> Here is the stacktrace
>>
>> Method <clinit> is not static in class file $Subclass_ClassUnderTest
>>
>> java.lang.ClassFormatError: Method <clinit> is not static in class file 
>> $Subclass_ClassUnderTest
>> at java.base/java.lang.ClassLoader.defineClass1(Native Method)
>> at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
>> at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:877)
>> at ClassUnderTestTestcase$3.<init>(ClassUnderTestTestcase.java:xx)
>> at 
>> ClassUnderTestTestcase.testSettersAndGetters(ClassUnderTestTestcase.java:xx)
>>
>
>
>  
>
>> I tried to investigate the bytecode and found something unusual(i guess)
>>
>> **With Java 11**
>>
>>     // access flags 0x100A
>>       private static synthetic $jacocoInit()[Z
>>         GETSTATIC ClassUnderTest.$jacocoData : [Z
>>         DUP
>>         IFNONNULL L0
>>         POP
>>         LDC -1475355800743669619
>>         LDC "ClassUnderTest"
>>         BIPUSH 64
>>         INVOKESTATIC 
>> org/jacoco/agent/rt/internal_1f1cc91/Offline.getProbes 
>> (JLjava/lang/String;I)[Z
>>         DUP
>>         PUTSTATIC ClassUnderTest.$jacocoData : [Z
>>        L0
>>
>> **With Java8**
>>
>>         // access flags 0x100A
>>       private static synthetic $jacocoInit()[Z
>>         GETSTATIC ClassUnderTest.$jacocoData : [Z
>>         DUP
>>         IFNONNULL L0
>>         POP
>>         LDC 4330111099009117958
>>         LDC "ClassUnderTest"
>>         BIPUSH 64
>>         INVOKESTATIC 
>> org/jacoco/agent/rt/internal_1f1cc91/Offline.getProbes 
>> (JLjava/lang/String;I)[Z
>>         DUP
>>         PUTSTATIC ClassUnderTest.$jacocoData : [Z
>>        L0
>>
>
> There is absolutely nothing unusual.
>  
>
>>
>> Any Idea?
>>
>
>
> I'm pretty sure that if you'll try the same without JaCoCo, then you'll 
> observe exactly the same problem, which means that it is not caused by 
> JaCoCo.
>
> Because your problem looks very similar to the following bug in JMockit - 
> https://github.com/jmockit/jmockit1/issues/590
> which according to http://jmockit.github.io/changes.html was fixed in 
> JMockit version 1.46.
>
>

-- 
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/5878dabf-c64f-446d-bf55-dea8cd2dcb1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to