Unable to create symbol table for -- IndexOutOfBoundsException

java

(James Miller) #1

When using SonarCloud we are getting the following error recently (as of Feb. 20th – it worked fine before then):

[ERROR] Unable to create symbol table for : C:\Projects\git\app-customer\bundle\src\main\java\com…\Account.java
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at org.sonar.java.resolve.TypeAndReferenceSolver.resolveClassType(TypeAndReferenceSolver.java:428)
at org.sonar.java.resolve.TypeAndReferenceSolver.resolveAs(TypeAndReferenceSolver.java:382)
at org.sonar.java.resolve.TypeAndReferenceSolver.resolveAs(TypeAndReferenceSolver.java:371)
at org.sonar.java.resolve.TypeAndReferenceSolver.resolveAs(TypeAndReferenceSolver.java:364)
at org.sonar.java.resolve.TypeAndReferenceSolver.visitAnnotation(TypeAndReferenceSolver.java:1130)
at org.sonar.java.model.declaration.AnnotationTreeImpl.accept(AnnotationTreeImpl.java:63)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:34)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitModifier(BaseTreeVisitor.java:338)
at org.sonar.java.model.declaration.ModifiersTreeImpl.accept(ModifiersTreeImpl.java:74)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:45)
at org.sonar.java.resolve.TypeAndReferenceSolver.visitClass(TypeAndReferenceSolver.java:141)
at org.sonar.java.model.declaration.ClassTreeImpl.accept(ClassTreeImpl.java:202)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:34)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitCompilationUnit(BaseTreeVisitor.java:52)
at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:66)
at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:121)
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:96)
at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:68)
at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:113)
at org.sonar.java.JavaSquid.scan(JavaSquid.java:107)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:92)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:367)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:362)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:359)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:325)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
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:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy21.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:104)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
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:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

This is happening for nearly every class in our project. When we use a local copy of SonarQube (7.6) it works just fine…I’m not sure what is going on. Any help would be great!


(Alexandre Gigleux) #3

Hello,

Last version of SonarJava deployed on SonarCloud is the 5.11 on the 20th of Feb
To confirm the problem is coming from it, can you deploy SonarJava 5.11 on your local SQ 7.6 ?

I guess the project you are working on is not open-source and you can’t share the source code but can you share a reproducer so we can work on it?

Thanks


(James Miller) #4

Switching to 5.11 of the SonarJava jar definitely causes the error. I haven’t been able to quite identify the code segment(s) that are really at the root of this problem to be able to create a reproducer we feel comfortable with. We will continue to look at it.


(James Miller) #5

Here is some sample code that creates the error.

SourceSystem.java

import org.codehaus.jackson.map.annotate.JsonSerialize;

public class SourceSystem {

	@JsonSerialize(using = StringBooleanSerializer.class)
	private boolean totalSystemTypeTested;

	public boolean isTotalSystemTypeTested() {
		return this.totalSystemTypeTested;
	}

	public void setTotalSystemTypeTested(boolean totalSystemTypeTested) {
		this.totalSystemTypeTested = totalSystemTypeTested;
	}

}

StringBooleanSerializer.java

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

public class StringBooleanSerializer extends JsonSerializer<Boolean> {

    @Override
    public void serialize(Boolean bool, JsonGenerator generator, SerializerProvider provider) throws IOException {
        generator.writeString(bool ? "Y" : "N");
    }   
}

Here are the Jackson dependancies we use:

	<dependency>
		<groupId>org.codehaus.jackson</groupId>
		<artifactId>jackson-core-asl</artifactId>
		<version>1.9.13</version>
	</dependency>

	<dependency>
		<groupId>org.codehaus.jackson</groupId>
		<artifactId>jackson-mapper-asl</artifactId>
		<version>1.9.13</version>
	</dependency>

(Alexandre Gigleux) #6

With the sample code provided, I’m not able to reproduce the failure with SQ 7.6 + SonarJava 5.11 + All Rules activated.

Which JDK, Maven versions are you using?

Do you confirm on your side, a maven project made of only these 2 files is triggering the failure?


(James Miller) #7

I am using JDK 1.8.0_201 and maven 3.2.5 I will create a special project with just those two files and the same POM file to reproduce. I will let you know what I find.


(James Miller) #8

I am also able to recreate it by separating those files into their own project with a modified pom file from a troubled project.


(James Miller) #9

I found the issue. It turned out to be a dependency upon

<group>org.apache.felix</group>
<artifact>org.osgi.compendium</artifact>

One I removed that dependency (turns out we didn’t even originally need it at all) then the project that depended upo in started working and the other projects that depended upon that project started working and so on.