Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OC-20 CLOV-1839 Clover fails to instrument source code with type annotations #20

Closed
marek-parfianowicz opened this issue Dec 15, 2019 · 1 comment · Fixed by #149
Closed
Labels
bug Something isn't working resolved
Milestone

Comments

@marek-parfianowicz
Copy link
Member

I have code annotated for Checker Framework:

protected final ListOrderedMap<@Interned String, Table> tables = ListOrderedMap.listOrderedMap(new ConcurrentHashMap<>());

The type annotation causes Clover instrumentation to throw the exception below. Removing the type annotation immediately fixes the problem. Surrounding it (e.g. /* CLOVER:OFF / @Interned / CLOVER:ON */) has no effect.

com.atlassian.clover.api.CloverException: myfile.java:87:5:unexpected token: protected
at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:159)
at com.atlassian.clover.CloverInstr.execute(CloverInstr.java:76)
at com.atlassian.clover.CloverInstr.mainImpl(CloverInstr.java:54)
at com.atlassian.maven.plugin.clover.internal.instrumentation.AbstractInstrumenter.instrumentSources(AbstractInstrumenter.java:197)
at com.atlassian.maven.plugin.clover.internal.instrumentation.AbstractInstrumenter.instrument(AbstractInstrumenter.java:72)
at com.atlassian.maven.plugin.clover.CloverInstrumentInternalMojo.execute(CloverInstrumentInternalMojo.java:289)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:353)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: line 87:5: unexpected token: protected
at com.atlassian.clover.instr.java.JavaRecognizer.field(JavaRecognizer.java:2440)
at com.atlassian.clover.instr.java.JavaRecognizer.classBlock(JavaRecognizer.java:1857)
at com.atlassian.clover.instr.java.JavaRecognizer.classDefinition(JavaRecognizer.java:865)
at com.atlassian.clover.instr.java.JavaRecognizer.typeDefinition2(JavaRecognizer.java:795)
at com.atlassian.clover.instr.java.JavaRecognizer.typeDefinition(JavaRecognizer.java:648)
at com.atlassian.clover.instr.java.JavaRecognizer.compilationUnit(JavaRecognizer.java:566)
at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:211)
at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:124)
Why it references protected instead of the annotation itself I have no idea, but I have attempted this on several different annotated files and it always spits out the first word on whatever line has the type annotation.

@marek-parfianowicz
Copy link
Member Author

Original report: https://bitbucket.org/openclover/clover/issues/20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant