>
> Hi, Thank you so much for answering. I have tried to exclude class from
> instrumentation
> in "instrument" goal.
I want use BlockBuilderStatus.class without instrumentation
> <execution>
>
<id>default-instrument</id>
> <goals>
> <goal>instrument</goal>
> </goals>
> <configuration>
> <excludes>
> <exclude>
> *.jar
> </exclude>
> <exclude>
> **/BlockBuilderStatus
> </exclude>
> </excludes>
> </configuration>
> </execution>
>
Its a multi-module project ,so I use an maven-antrun-plugin. and it
failes with error message: "Failed to execute goal
org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project
common-api: An Ant BuildException has occured: Error while creating report:
Error while analyzing xxx.class. Class xxx is already instrumented. "
"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." where can I find a sample? actually,if
BlockBuilderStatus.class is instrumented ,it will go into this branch '
if (clazz.isArray()) {
throw new IllegalArgumentException(String.format("Cannot
determine size of %s because it contains an array", clazz.getSimpleName()));
}' ,and this BlockBuilderStatus.class is referenced by many
classes
>
在 2017年1月4日星期三 UTC+8上午5:15:33,Evgeny Mandrikov写道:
>
>
> First of all quoting JaCoCo FAQ item "My code uses reflection. Why does it
> fail when I execute it with JaCoCo?" ( see
> http://www.jacoco.org/jacoco/trunk/doc/faq.html ) :
> 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.
>
> And answering your question about exclusions: there is known inconsistency
> between exclusion patterns for instrumentation and report generation ( see
> https://github.com/jacoco/jacoco/issues/34 ): first one accepts Java or
> VM class name, while second one accepts file name. So if you want to
> exclude class from instrumentation - specify it as " **/BlockBuilderStatus"
> for "instrument" goal. Or as a workaround - you can specify
> "**/BlockBuilderStatus*", which will also work for "report" goal.
>
> On Tuesday, January 3, 2017 at 3:34:02 AM UTC+1, [email protected]
> <javascript:> wrote:
>>
>> hi,
>>
>> I want to skip instrument a class named BlockBuilderStatus.class ,but
>> it didn't work , here is my configuration ,is there anything wrong?
>>
>> <plugin>
>> <groupId>org.jacoco</groupId>
>> <artifactId>jacoco-maven-plugin</artifactId>
>> <version>0.7.7.201606060606</version>
>> <executions>
>> <execution>
>> <id>jacoco-initialize</id>
>> <goals>
>> <goal>prepare-agent</goal>
>> </goals>
>> </execution>
>> <execution>
>> <id>jacoco-site</id>
>> <phase>package</phase>
>> <goals>
>> <goal>report</goal>
>> </goals>
>> </execution>
>> </executions>
>> <configuration>
>> <excludes>
>> <exclude>
>> *.jar
>> </exclude>
>> <exclude>
>> **/BlockBuilderStatus.class
>> </exclude>
>> </excludes>
>> </configuration>
>> </plugin>
>>
>> Method deepInstanceSize in BlockBuilderStatus.java will be invoked
>> when the class is loaded , and it throws an Exception when use jacoco , it
>> will go into 'if (clazz.isArray())' this branch. so I want to skip
>> instrument the class .
>>
>> private static int deepInstanceSize(Class<?> clazz)
>> {
>> if (clazz.isArray()) {
>> throw new IllegalArgumentException(String.format("Cannot
>> determine size of %s because it contains an array", clazz.getSimpleName()));
>> }
>> if (clazz.isInterface()) {
>> throw new IllegalArgumentException(String.format("%s is an
>> interface", clazz.getSimpleName()));
>> }
>> if (Modifier.isAbstract(clazz.getModifiers())) {
>> throw new IllegalArgumentException(String.format("%s is
>> abstract", clazz.getSimpleName()));
>> }
>> if (!clazz.getSuperclass().equals(Object.class)) {
>> throw new IllegalArgumentException(String.format("Cannot
>> determine size of a subclass. %s extends from %s", clazz.getSimpleName(),
>> clazz.getSuperclass().getSimpleName()));
>> }
>>
>> int size = ClassLayout.parseClass(clazz).instanceSize();
>> for (Field field : clazz.getDeclaredFields()) {
>> if (!field.getType().isPrimitive()) {
>> size += deepInstanceSize(field.getType());
>> }
>> }
>> return size;
>> }
>>
>>
--
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/df341eb9-9817-4b5e-a4f5-d8e8e2dfa0b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.