Home > Enterprise >  SonarQube is unable to analyze file: bridge method not marked as synthetic
SonarQube is unable to analyze file: bridge method not marked as synthetic

Time:11-10

I've got this exception when analyzing a project with SonarQube (the project utilizes JavaFX, Spring, AOP with compile-time weaving). I'm using the maven plugin to run the analysis sonar:sonar but I get the same errors with a Jenkins plugin. I'm running the sonar plugin on a super-pom used with maven's reactor plugin. What are my solutions?

        [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project [...]-gui-product: SonarQube is unable to analyze fil
        e : '[...]ConfigurationController.java': bridge method not
        marked as synthetic in class com/[...]/core/domain/events/DomainEvent -> [Help 1]
        org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project [...]
        -gui-product: SonarQube is unable to analyze file : 'D:\projects\[...]gui\application\controller\
        ConfigurationController.java'
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        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:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        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:483)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
        Caused by: org.apache.maven.plugin.MojoExecutionException: SonarQube is unable to analyze file : 'D:\projects\[...]application\controller\ConfigurationController.java'
        at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
        at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:139)
        at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:138)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
        Caused by: org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : 'D:\projects\[...]\ConfigurationController.java'
        at org.sonar.java.ast.AstScanner.simpleScan(AstScanner.java:114)
        at org.sonar.java.ast.AstScanner.scan(AstScanner.java:75)
        at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:122)
        at org.sonar.java.JavaSquid.scan(JavaSquid.java:115)
        at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:92)
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:122)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:222)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:223)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:65)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:52)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:128)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:171)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        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:483)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:135)
        ... 22 more
        Caused by: java.lang.IllegalStateException: bridge method not marked as synthetic in class com/[...]core/domain/events/DomainEvent
        at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
        at org.sonar.java.resolve.BytecodeVisitor.visitMethod(BytecodeVisitor.java:204)
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:911)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:693)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
        at org.sonar.java.resolve.BytecodeCompleter.complete(BytecodeCompleter.java:100)
        at org.sonar.java.resolve.Symbol.complete(Symbol.java:98)
        at org.sonar.java.resolve.Type.getSymbol(Type.java:69)
        at org.sonar.java.checks.InstanceOfAlwaysTrueCheck.typeInherits(InstanceOfAlwaysTrueCheck.java:62)
        at org.sonar.java.checks.InstanceOfAlwaysTrueCheck.visitNode(InstanceOfAlwaysTrueCheck.java:49)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:95)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.scanTree(SubscriptionVisitor.java:73)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.scanFile(SubscriptionVisitor.java:67)
        at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:122)
        at com.sonar.sslr.impl.ast.AstWalker.walkAndVisit(AstWalker.java:67)
        at org.sonar.java.ast.AstScanner.simpleScan(AstScanner.java:107)
        ... 59 more

CodePudding user response:

Your project does 'AOP with compile-time weaving', so you might be impacted by this AspectJ bug:

  • Bug #467415 - Weaver created bridge methods missing ACC_SYNTHETIC - fixed in AspectJ v1.8.6

It causes flags in bytecode to be incorrect (i.e. bridge methods missing the Synthetic flag), so when that same bytecode is visited by the SonarQube Java Plugin, it fails accordingly: 'bridge method not marked as synthetic'.

  • Related