Test fails-can not access a member of class...with modifiers "private static transient"

1,793 views
Skip to first unread message

vered.co...@gmail.com

unread,
May 28, 2018, 5:05:30 PM5/28/18
to JaCoCo and EclEmma Users
Hello,

I'm trying to configure jacoco for thresholds and exclude some files from the coverage in our multi maven project. I use 0.7.9 version.

In my parent pom I use:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.percentage.instruction}</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

in one of the child maven modules there is a test that fails, I get this error only because I added jacoco in the parent.

java.lang.RuntimeException: Got: java.lang.IllegalAccessException: Class com.sun.tools.jdi.EventRequestManagerImpl can not access a member of class com.sun.tools.jdi.JDWP$EventKind with modifiers "private static transient"

However in the test itself I don't do anything that access static transient fields..It seems to come from a much lower level which I don't control.

I don't mind to skip this test from the coverage at all but I tried to add
<configuration>
<excludes>
<exclude>*NameOfTest*</exclude>
</excludes>
</configuration>
in any phase (I tried everything :( ) but it still fails for the same error.
I'm really stuck on this thing, I read a lot of documentation but nothing helped me here.
Please I hope you could help me with this.

Thanks a lot
Regards
Vered

Marc Hoffmann

unread,
May 29, 2018, 2:52:47 AM5/29/18
to jac...@googlegroups.com
Hi,

looks like the instrumented com.sun.* code can't cope with the
additional fields JaCoCo adds. Please see our FAQ for a explanation
(https://www.jacoco.org/jacoco/trunk/doc/faq.html)

As a workaround I would exclude com.sun.* packages from instrumentation
-- not the test itself.

Regards,
-marc


------------

My code uses reflection. Why does it fail when I execute it with JaCoCo?

To collect execution data JaCoCo instruments the classes under test
which adds two members to the classes: A private static field
$jacocoData and a private static method $jacocoInit(). Both members are
marked as synthetic.

Please change your code to ignore synthetic members. This is a good
practice anyways as also the Java compiler creates synthetic members in
certain situation.

vered.co...@gmail.com

unread,
May 29, 2018, 3:54:56 AM5/29/18
to JaCoCo and EclEmma Users
Hi Marc,

Thank you for your quick response.

I added this configuration and it finally helped!! :-)


<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>

<configuration>
<excludes>
<exclude>com.sun.*</exclude>
</excludes>
</configuration>
</plugin>

Thank you so much!!
Regards,
Vered

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages