[4.3.1] Exception "Unexpected token: to" after upgrading to 4.3.0

Issue #72 resolved
Bertolt Meier
created an issue

Hi,

I tried to switch to OpenClover version 4.3.0 from previous version, but am getting an exception during the instrumentation build with maven. This does not happen with OpenClover 4.2.1.

{code} [INFO] OpenClover Version 4.3.0, built on August 03 2018 (build-1010) [INFO] Updating existing database at '/Users/myUser/Projects/client_folder/client_project/testing_dependencies/target/clover/clover.db'. [INFO] Processing files at 1.8 source level. [INFO] /Users/myUser/Projects/client_folder/client_project/brightcove_connector/brightcove-services/src/main/java/org/jsonBC/JSONTokener.java:385:29:unexpected token: to [INFO] Instrumentation error com.atlassian.clover.api.CloverException: /Users/myUser/Projects/client_folder/client_project/brightcove_connector/brightcove-services/src/main/java/org/jsonBC/JSONTokener.java:385:29:unexpected token: to 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 com.atlassian.maven.plugin.clover.CloverSetupMojo.execute(CloverSetupMojo.java:31) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 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:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) 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:497) 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 385:29: unexpected token: to at com.atlassian.clover.instr.java.JavaRecognizer.parameterDeclaration(JavaRecognizer.java:3813) at com.atlassian.clover.instr.java.JavaRecognizer.parameterDeclarationList(JavaRecognizer.java:2975) at com.atlassian.clover.instr.java.JavaRecognizer.field(JavaRecognizer.java:2639) at com.atlassian.clover.instr.java.JavaRecognizer.classBlock(JavaRecognizer.java:2126) at com.atlassian.clover.instr.java.JavaRecognizer.classDefinition(JavaRecognizer.java:1134) at com.atlassian.clover.instr.java.JavaRecognizer.typeDefinition2(JavaRecognizer.java:1064) at com.atlassian.clover.instr.java.JavaRecognizer.typeDefinition(JavaRecognizer.java:968) at com.atlassian.clover.instr.java.JavaRecognizer.compilationUnit(JavaRecognizer.java:880) at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:211) at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:124) ... 28 more {code}

I am running {code} $ mvn -version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00) Maven home: /usr/local/Cellar/maven/3.3.9/libexec Java version: 1.8.0_45, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac" {code}

Find the java class attached for which this exception is raised.

Comments (12)

  1. Marek Parfianowicz

    The smallest reproducible test case:

    class A {
        void a(int to) { }
    }
    

    Workaround: rename 'to' a different name.

    Cause: grammar

    parameter declaration conflicts with the

    "exports <package> to <name>, <name>"

    from module-info.java.

  2. Marek Parfianowicz

    Update: it fails on any of the tokens allowed in module-info files (exports, imports, uses, to, open etc) in regular source files.

    I'm already working on this. Initially I wanted to use a common grammar for both modules and regular files but I see it didn't work as expected.

    I've already split grammars and working on tests. I'll also run Clover on several open source projects (like openjdk or guava or apache Commons ) to ensure it works fine in all cases.

  3. Marek Parfianowicz

    I tested the fix on sources of: OpenJDK9, Jetty server, Guava and a number of Apache Commons libraries. Apart from few known issues (instrumentation of type annotations feature request, double ;; with import, [][]::new reference) I found only one bug ('try(xyz)' with no type), which is not a regression and is minor in my opinion.

    The problem described by you no longer happens so I'm gonna release 4.3.1 this week.

  4. Bertolt Meier reporter

    Hi Marek. Sorry, I was out sick for the past week. I compiled clover and clover-maven-plugin locally in version 4.3.1-SNAPSHOT and the build of our software ran like a charm.

    Thanks for fixing.

  5. Log in to comment