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

Bytecode issue: bridge method not marked as synthetic #795

Closed
hogmoru opened this Issue Jan 10, 2017 · 7 comments

Comments

Projects
None yet
3 participants
@hogmoru

hogmoru commented Jan 10, 2017

Hi,

SonarQube complains that some bytecode from MapDB is invalid.

Here is a very simple maven project to reproduce:

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

        <modelVersion>4.0.0</modelVersion>
        <groupId>org.mapdb</groupId>
        <artifactId>sonarqube-issue-demo</artifactId>
        <version>1.0-SNAPSHOT</version>

        <dependencies>
                <dependency>
                        <groupId>org.mapdb</groupId>
                        <artifactId>mapdb</artifactId>
                        <version>3.0.2</version>
                </dependency>
        </dependencies>
</project>

src/main/java/foo/Foo.java:

package foo;
import org.mapdb.DB;
class Foo {
        private DB db = null;
}

Then if I execute mvn package sonar:sonar, I get:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project sonarqube-issue-demo: SonarQube is unable to analyze file : '/afs/RDwork/hmoreau/dev/mapdb/tmp/src/main/java/foo/Foo.java': bridge method not marked as synthetic in class org/mapdb/HTreeMap$KeySet

Fundamental issue might belong to Kotlin, not sure, I'll try to isolate this independently from MapDB, but the fact is that for now a Java project that uses MapDB cannot be analyzed with SonarQube.

@Odyldzhon

This comment has been minimized.

Show comment
Hide comment
@Odyldzhon

Odyldzhon Jan 11, 2017

I have faced with the same issue(

Odyldzhon commented Jan 11, 2017

I have faced with the same issue(

@hogmoru

This comment has been minimized.

Show comment
Hide comment
@hogmoru

hogmoru Jan 11, 2017

I posted a message to Kotlin forum, and they created an issue for this.
So, root problem is in Kotlin, hopefully they'll fix that in an ulterior version.
In the meantime, a project that uses MapDB cannot be analyzed with SonarQube, so I would suggest to leave this issue open until Kotlin is fixed and a new version of MapDB is recompiled/redeployed with that version of Kotlin.

hogmoru commented Jan 11, 2017

I posted a message to Kotlin forum, and they created an issue for this.
So, root problem is in Kotlin, hopefully they'll fix that in an ulterior version.
In the meantime, a project that uses MapDB cannot be analyzed with SonarQube, so I would suggest to leave this issue open until Kotlin is fixed and a new version of MapDB is recompiled/redeployed with that version of Kotlin.

@hogmoru

This comment has been minimized.

Show comment
Hide comment
@hogmoru

hogmoru Jan 11, 2017

Or maybe the problem is in Sonar :)
I also posted on Sonar google group, asking who is right between Kotlin compiler and Sonar analyzer, and more importantly is it a good idea to let the analyzer crash on this... and one Sonar dev tends to agree that, although Kotlin should mark their bridge methods as synthetic, the Sonar analyzer is too strict, and has created an issue in their system to deal with this on their side.

hogmoru commented Jan 11, 2017

Or maybe the problem is in Sonar :)
I also posted on Sonar google group, asking who is right between Kotlin compiler and Sonar analyzer, and more importantly is it a good idea to let the analyzer crash on this... and one Sonar dev tends to agree that, although Kotlin should mark their bridge methods as synthetic, the Sonar analyzer is too strict, and has created an issue in their system to deal with this on their side.

@jankotek

This comment has been minimized.

Show comment
Hide comment
@jankotek

jankotek Jan 12, 2017

Owner

I experienced similar issue with upgrade to Scala 2.12.1, demo project is here: https://github.com/rtkaczyk/mapdb212

if you compile scala project with sbt test it as is you will get:

[error] Class org.mapdb.DB$Maker not found - continuing with a stub.

I can not run sonar from maven, mvn package sonar:sonar reports it cannot connect to local sonar server.

Owner

jankotek commented Jan 12, 2017

I experienced similar issue with upgrade to Scala 2.12.1, demo project is here: https://github.com/rtkaczyk/mapdb212

if you compile scala project with sbt test it as is you will get:

[error] Class org.mapdb.DB$Maker not found - continuing with a stub.

I can not run sonar from maven, mvn package sonar:sonar reports it cannot connect to local sonar server.

@hogmoru

This comment has been minimized.

Show comment
Hide comment
@hogmoru

hogmoru Jan 15, 2017

Running sonar from maven still involves setting up a sonar server as far as I can tell. So I guess it depends how bad you want to reproduce :)

The issue with Scala you mention makes me think perhaps not everything in the JVM world is ready to deal with bytecode generated by Kotlin compiler, and some adaptations are in order.

I honestly cannot tell who is right or wrong, which side needs to change, but I don't see what can be done with MapDB itself: either Kotlin compiler is faulty, or Scala & SonarQube are faulty.

So after all, I think it's OK if you close the issue here: Sonar devs said it's on their end, and a fix is on the way. Also, other "victims" searching for information about this error will still be able to find this page.

hogmoru commented Jan 15, 2017

Running sonar from maven still involves setting up a sonar server as far as I can tell. So I guess it depends how bad you want to reproduce :)

The issue with Scala you mention makes me think perhaps not everything in the JVM world is ready to deal with bytecode generated by Kotlin compiler, and some adaptations are in order.

I honestly cannot tell who is right or wrong, which side needs to change, but I don't see what can be done with MapDB itself: either Kotlin compiler is faulty, or Scala & SonarQube are faulty.

So after all, I think it's OK if you close the issue here: Sonar devs said it's on their end, and a fix is on the way. Also, other "victims" searching for information about this error will still be able to find this page.

@jankotek

This comment has been minimized.

Show comment
Hide comment
@jankotek

jankotek Feb 6, 2017

Owner

Closing, not mapdb issue. I opened another issue for Scala related problems: #801

Owner

jankotek commented Feb 6, 2017

Closing, not mapdb issue. I opened another issue for Scala related problems: #801

@jankotek jankotek closed this Feb 6, 2017

@hogmoru

This comment has been minimized.

Show comment
Hide comment
@hogmoru

hogmoru Feb 8, 2017

Leaving a comment for anyone who still gets this error and lands on this page: the issue has been fixed in SonarJava 4.5, released yesterday (that's the "Java" plugin within Sonar/SonarQube).

hogmoru commented Feb 8, 2017

Leaving a comment for anyone who still gets this error and lands on this page: the issue has been fixed in SonarJava 4.5, released yesterday (that's the "Java" plugin within Sonar/SonarQube).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment