Update of sonar plugins to be compilable with java11

Hello everybody,

when will for example the sonar-java-plugin be released, so that it can be compiled with java11?
For now java8 is enforced, if I understand it correctly:

<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<maven.compiler.release>8</maven.compiler.release>
</properties>

As we run the new server version that needs java11 we have to compile our code with java8 to fit the used plugin.

If done wrong, this leads to the following exception while the scan:
ERROR: Error during SonarQube Scanner execution
java.lang.ClassCastException: …MyCheck incompatible with org.sonar.java.ast.visitors.SubscriptionVisitor
at org.sonar.java.model.VisitorsBridge$ScannerRunner.lambda$new$0(VisitorsBridge.java:263)
-> MyCheck extends IssuableSubscriptionVisitor

Thanks for your help.

Regards

hello @VaSie,

sonar-java (and other plugins) can be compiled with Java 11 (we actually use Java 11 to compile it), they however can be used also on Java 8.

Your error is not due to Java version used to compile. I assume you are trying to develop custom rules plugin. Did you follow the instructions in https://github.com/SonarSource/sonar-java/blob/master/docs/CUSTOM_RULES_101.md#looking-at-the-pom ?

Can you please post full exception message?

Hello @saberduck, I did follow the instruction in developing custom rules plugin; however, I am getting these errors I am unable to figure out.
Below is the errors->>>>>

java.lang.NoClassDefFoundError: org/sonar/api/config/internal/MapSettings
at org.sonar.samples.java.checks.MyFirstCustomCheckTest.test(MyFirstCustomCheckTest.java:10)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: org.sonar.api.config.internal.MapSettings
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
… 24 more

Can you help you in this regards please.

Here are my files to forge rules:

@weakon123-stack, sorry are you the same person as @VaSie ? Your error seems to be completely different from the original post in this topic. Please start a new topic if you have different issue.

1 Like