Weird Java error when trying to use a custom SubscriptionVisitor

Hello everyone,

I have written some code to detect false-positive issues of a sonar rule. (relates to this thread.). It works fine when I run it as a standalone java program.

Then I included this in a plugin to execute via a PostProjectAnalysisTask so I can run this within the Sonarqube server. Server starts up fine but when I run an analysis I get a strange java error.

My code:

Path srcFile = Files.createTempFile("sonar-src-", ".java");
Files.write(srcFile, src.getBytes(), StandardOpenOption.WRITE);
InputFile inputFile = new GeneratedFile(srcFile);
JavaAstScanner scanner = new JavaAstScanner(null);
scanner.setVisitorBridge(new VisitorsBridge(new MethodVisitor(sonarIssueService, issue, nullableEntity)));
public class MethodVisitor extends SubscriptionVisitor {
    public List<Kind> nodesToVisit() {
        return Collections.singletonList(Kind.METHOD);

    public void visitNode(@Nonnull Tree tree) {
        tree.accept(new StatementVisitor(sonarIssueService, issue, nullableEntity));
public class StatementVisitor extends BaseTreeVisitor {
    // my logic here

Java error:

2024.06.07 08:32:57 ERROR ce[682c0e66-06ab-45eb-a75d-49e461e4b6cd][o.s.c.t.s.ComputationStepExecutor] Execution of listener failed
java.lang.VerifyError: Bad type on operand stack
Exception Details:
    org/sonar/java/model/VisitorsBridge.lambda$filterVisitors$0(Lorg/sonar/java/model/VisitorsBridge$IssuableSubscriptionVisitorsRunner;Ljava/util/List;Lorg/sonar/plugins/java/api/JavaCheck;)V @14: invokevirtual
    Type 'org/sonar/plugins/java/api/IssuableSubscriptionVisitor' (current frame, stack[1]) is not assignable to 'org/sonar/java/ast/visitors/SubscriptionVisitor'
  Current Frame:
    bci: @14
    flags: { }
    locals: { 'org/sonar/java/model/VisitorsBridge$IssuableSubscriptionVisitorsRunner', 'java/util/List', 'org/sonar/plugins/java/api/JavaCheck', 'org/sonar/plugins/java/api/IssuableSubscriptionVisitor' }
    stack: { 'org/sonar/java/model/VisitorsBridge$IssuableSubscriptionVisitorsRunner', 'org/sonar/plugins/java/api/IssuableSubscriptionVisitor' }
    0000000: 2cc1 01ca 9900 102c c001 ca4e 2a2d b601
    0000010: cca7 0019 2cc1 00cd 9900 122c c000 cd3a
    0000020: 042b 1904 b900 8702 0057 b1
  Stackmap Table:

	at com.example.testing.issue.FalsePositiveIssueDetector.verifyIssue(
	at com.example.testing.issue.FalsePositiveIssueDetector.processSonarIssue(
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at com.example.testing.issue.PostAnalysisIssueVerifier.finished(
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(
	at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(
	at org.sonar.ce.task.step.ComputationStepExecutor.execute(
	at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(
	at org.sonar.ce.taskprocessor.CeWorkerImpl$
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(
	at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(
	at java.base/java.util.concurrent.Executors$ Source)
	at java.base/ Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$ Source)
	at java.base/ Source)

My efforts to figure this out had no luck so far. Has any of you seen something like this? Any clues?

Some useful info:

  • Sonarqube version: v10.5.1 (Java 17.0.11)
  • Local javac version: 17.0.9
  • I had to bundle with the plugin as I’m using an as input file. Otherwise I get a CNF exception.

Thank you,

On a related note, it’s weird why it gives me CNF for as well as for if I don’t bundle while the server already have the sonar-java-plugin- Is there any explanations for this? (I’m digging up on this because I suspect there’s a chance a duplicated runtime dependency to cause above issue.)

Hello @Bhathiya,

It seems that the error is due to the fact that you are using classes that are not part of the public API of SonarJava (SubscriptionVisitor and VisitorsBridge). Can you please try making MethodVisitor a subclass of IssuableSubscriptionVisitor instead of SubscriptionVisitor? If the error persists, could you please provide a reproducer or a little more information about the structure of your project?