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

Unable to use SonarQube tool with scala 2.12.8 #11352

Open
asenovm opened this issue Jan 15, 2019 · 4 comments
Open

Unable to use SonarQube tool with scala 2.12.8 #11352

asenovm opened this issue Jan 15, 2019 · 4 comments

Comments

@asenovm
Copy link

asenovm commented Jan 15, 2019

Hello,

we are using SonarQube (https://www.sonarqube.org/) to detect different kinds of issues with our code (our stack is Java 8 + Akka, but we are using some scala constructs in our code every now and then). After updating one of the libraries we are using to a new version SonarQube started outputting multiple errors like the one below:

Unable to create symbol table for : <OurClass.java>
java.lang.IllegalStateException: bridge method not marked as synthetic in class scala/collection/immutable/Stream
	at com.google.common.base.Preconditions.checkState(Preconditions.java:174) ~[guava-19.0.jar:na]
	at org.sonar.java.resolve.BytecodeVisitor.visitMethod(BytecodeVisitor.java:210) ~[java-frontend-4.2.jar:na]
	at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:911) ~[asm-debug-all-5.0.3.jar:5.0.3]
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:693) ~[asm-debug-all-5.0.3.jar:5.0.3]
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:506) ~[asm-debug-all-5.0.3.jar:5.0.3]

Basically the error is always java.lang.IllegalStateException: bridge method not marked as synthetic and the scala class that is mentioned varies.

I noticed that the new version of the library introduces a dependency to scala 2.12.8 instead of scala 2.12.7 (which is the scala version required by the old version of the library) and one of the changes mentioned in the release notes of scala 2.12.8 is:

Don't emit static forwarders (which simplify the use of methods in top-level objects from Java) for bridge methods (#7469)
The second fix is not binary compatible: the 2.12.8 compiler omits certain methods that are generated by earlier 2.12 compilers. However, we believe that these methods are never used and existing compiled code will continue to work. See the pull request description for more details.

So I believe that's what causes the SonarQube errors. Can someone please look into this?

Thanks,
Martin

@SethTisue
Copy link
Member

this is @lrytz's area of expertise / cross to bear

@lrytz
Copy link
Member

lrytz commented Jan 18, 2019

Hi Martin

Could you double-check which exact jar/classfile is causing the issue? In 2.12.7 we started adding the ACC_BRIDGE flag to some static methods, but in 2.12.8 we stopped emitting these static bridge methods completely. (See scala/scala#7469 (comment)). So I'm a bit surprised you see this message due to a 2.12.7 -> 2.12.8 update - I'd be less surprised if this happened for a 2.12.6 -> 2.12.7 update.

Can you get the tool to tell you which method is the one causing the problem?

@asenovm
Copy link
Author

asenovm commented Jan 24, 2019

@lrytz thanks a lot for the response and very sorry for the belated reply. The only exceptions I'm seeing in the logs are:

  • java.lang.IllegalStateException: bridge method not marked as synthetic in class scala/collection/immutable/Stream
  • java.lang.IllegalStateException: bridge method not marked as synthetic in class scala/collection/GenMap

The only change that was introduced with the commit when these exceptions first started happening is updating:

The only suspicious thing I could find there is updating org.scala-lang.scala-library and org.scala-lang.scala-reflect from 2.12.7 to 2.12.8.

@adriaanm
Copy link
Contributor

adriaanm commented Feb 7, 2019

It looks like Kafka 2.1.0 itself was compiled with Scala 2.12.7 (and thus depends on scala-library 2.12.7) -- could you check the classpath to ensure only the 2.12.8 Scala library is on there? (2.12.8 and 2.12.7 are binary compatible, but the most recent version should not have the issue with bridges, as Lukas said)

PS: and indeed, Kafka 2.0.0 was using Scala 2.12.6, so that would align well with Lukas's expectation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants