This repository contains source code of OpenClover Core as well as its integrations: Clover-for-Ant, Clover-for-Eclipse and Clover-for-IDEA plugins. Sources are licensed under Apache 2.0 license.
Other
61
stars
16
forks
source link
Clover fails to instrument source code with TYPE_USE annotations in throws clause #170
package typeannotation.throwsclause;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
public class TypeAnnotationThrowsClause {
public void foo() throws @AnnotationForType1 Exception {
try {
throw new Exception();
} finally {
}
}
}
@Retention(RUNTIME) @Target({ElementType.TYPE_USE})
@interface AnnotationForType1 {
}
This code causes Clover instrumentation to throw the exception below. Removing the type annotation immediately fixes the problem.
C:\home\satob\git\JavaSyntaxTestcase\build.xml:31: line 10:30: expecting IDENT, found '@'
at clover.antlr.Parser.match(Parser.java:211)
at com.atlassian.clover.instr.java.JavaRecognizer.identifier(JavaRecognizer.java:575)
at com.atlassian.clover.instr.java.JavaRecognizer.throwsClause(JavaRecognizer.java:3150)
at com.atlassian.clover.instr.java.JavaRecognizer.field(JavaRecognizer.java:2747)
at com.atlassian.clover.instr.java.JavaRecognizer.classBlock(JavaRecognizer.java:2229)
at com.atlassian.clover.instr.java.JavaRecognizer.classDefinition(JavaRecognizer.java:1237)
at com.atlassian.clover.instr.java.JavaRecognizer.typeDefinition2(JavaRecognizer.java:1167)
at com.atlassian.clover.instr.java.JavaRecognizer.typeDefinition(JavaRecognizer.java:1071)
at com.atlassian.clover.instr.java.JavaRecognizer.compilationUnit(JavaRecognizer.java:983)
at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:211)
at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:124)
at com.atlassian.clover.ant.taskdefs.CloverCompilerAdapter.setJavac(CloverCompilerAdapter.java:223)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1349)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1092)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
at org.apache.tools.ant.Main.runBuild(Main.java:818)
at org.apache.tools.ant.Main.startAnt(Main.java:223)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
When you have the folowing code:
This code causes Clover instrumentation to throw the exception below. Removing the type annotation immediately fixes the problem.