java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

java

(Aaron Whiteside) #1

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    Maven Plugin: 3.5.0.1254
    SonarQube: Developer Edition Version 7.3 (build 15553)

  • error observed (wrap logs/code around triple quote ``` for proper formatting)

[ERROR] Unable to run check class org.sonar.java.se.SymbolicExecutionVisitor -  on file /mnt/ebs1/jenkins/workspace/g-pd_onboardingserv_develop-BHYVP3SWVDSJ6BQG5DGQ4QTAIYTWLMXTBAZDYOZB6QHQCIJ7XE4A/server/service/src/main/java/com/yapstone/onboarding/service/mapper/BuilderFactory.java, To help improve SonarJava, please report this problem to SonarSource : see https://www.sonarqube.org/community/
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.BytecodeMethodVisitor.visitParameterAnnotation(BytecodeMethodVisitor.java:64)
        at org.sonar.java.resolve.BytecodeMethodVisitor.visitTypeAnnotation(BytecodeMethodVisitor.java:75)
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1176)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:631)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:355)
        at org.sonar.java.resolve.BytecodeCompleter.complete(BytecodeCompleter.java:86)
        at org.sonar.java.resolve.JavaSymbol.complete(JavaSymbol.java:110)
        at org.sonar.java.resolve.JavaSymbol$TypeJavaSymbol.getSuperclass(JavaSymbol.java:361)
        at org.sonar.java.resolve.JavaSymbol$TypeJavaSymbol.superClass(JavaSymbol.java:455)
        at org.sonar.java.resolve.JavaSymbol$TypeJavaSymbol.superTypes(JavaSymbol.java:422)
        at org.sonar.java.resolve.ClassJavaType.superTypeContains(ClassJavaType.java:85)
        at org.sonar.java.resolve.ClassJavaType.isSubtypeOf(ClassJavaType.java:57)
        at org.sonar.java.se.checks.UnclosedResourcesCheck.needsClosing(UnclosedResourcesCheck.java:196)
        at org.sonar.java.se.checks.UnclosedResourcesCheck.access$800(UnclosedResourcesCheck.java:68)
        at org.sonar.java.se.checks.UnclosedResourcesCheck$PostStatementVisitor.methodOpeningResource(UnclosedResourcesCheck.java:487)
        at org.sonar.java.se.checks.UnclosedResourcesCheck$PostStatementVisitor.visitMethodInvocation(UnclosedResourcesCheck.java:473)
        at org.sonar.java.model.expression.MethodInvocationTreeImpl.accept(MethodInvocationTreeImpl.java:96)
        at org.sonar.java.se.checks.UnclosedResourcesCheck.checkPostStatement(UnclosedResourcesCheck.java:150)
        at org.sonar.java.se.CheckerDispatcher.executePost(CheckerDispatcher.java:106)
        at org.sonar.java.se.CheckerDispatcher.addTransition(CheckerDispatcher.java:97)
        at org.sonar.java.se.CheckerDispatcher.executePost(CheckerDispatcher.java:118)
        at org.sonar.java.se.CheckerDispatcher.addTransition(CheckerDispatcher.java:97)
        at org.sonar.java.se.checks.NullDereferenceCheck.checkPostStatement(NullDereferenceCheck.java:192)
        at org.sonar.java.se.CheckerDispatcher.executePost(CheckerDispatcher.java:106)
        at org.sonar.java.se.CheckerDispatcher.addTransition(CheckerDispatcher.java:97)
        at org.sonar.java.se.CheckerDispatcher.executeCheckPostStatement(CheckerDispatcher.java:69)
        at org.sonar.java.se.ExplodedGraphWalker.executeMethodInvocation(ExplodedGraphWalker.java:705)
        at org.sonar.java.se.ExplodedGraphWalker.visit(ExplodedGraphWalker.java:541)
        at org.sonar.java.se.ExplodedGraphWalker.execute(ExplodedGraphWalker.java:250)
        at org.sonar.java.se.ExplodedGraphWalker.visitMethod(ExplodedGraphWalker.java:210)
        at org.sonar.java.se.ExplodedGraphWalker.visitMethod(ExplodedGraphWalker.java:202)
        at org.sonar.java.se.SymbolicExecutionVisitor.execute(SymbolicExecutionVisitor.java:78)
        at org.sonar.java.se.SymbolicExecutionVisitor.visitNode(SymbolicExecutionVisitor.java:64)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:95)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:120)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:120)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.scanTree(SubscriptionVisitor.java:78)
        at org.sonar.java.ast.visitors.SubscriptionVisitor.scanFile(SubscriptionVisitor.java:64)
        at org.sonar.java.se.SymbolicExecutionVisitor.scanFile(SymbolicExecutionVisitor.java:54)
        at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:135)
        at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:124)
        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:116)
        at org.sonar.java.JavaSquid.scan(JavaSquid.java:110)
        at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:93)
        at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
        at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
        at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
        at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:166)
        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:300)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:295)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:293)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:293)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:269)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
        at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.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.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
        at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
        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.$Proxy23.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
        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:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
        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)
 
  • steps to reproduce
    This happens to many seemingly normal classes, but here is the first one for reference.
package com.yapstone.onboarding.service.mapper;

import com.yapstone.onboarding.service.model.Action;
import com.yapstone.onboarding.service.model.ActionStatus;
import com.yapstone.onboarding.service.model.Address;
import com.yapstone.onboarding.service.model.ApplicantConsent;
import com.yapstone.onboarding.service.model.Asset;
import com.yapstone.onboarding.service.model.BankAccount;
import com.yapstone.onboarding.service.model.BankAccountData;
import com.yapstone.onboarding.service.model.BeneficialOwner;
import com.yapstone.onboarding.service.model.BusinessApplicant;
import com.yapstone.onboarding.service.model.BusinessId;
import com.yapstone.onboarding.service.model.BusinessOwner;
import com.yapstone.onboarding.service.model.BusinessProfile;
import com.yapstone.onboarding.service.model.Consent;
import com.yapstone.onboarding.service.model.Contract;
import com.yapstone.onboarding.service.model.CustomerHistory;
import com.yapstone.onboarding.service.model.DeactivateRequest;
import com.yapstone.onboarding.service.model.DeactivateResponse;
import com.yapstone.onboarding.service.model.EntityProductStatus;
import com.yapstone.onboarding.service.model.GovernmentId;
import com.yapstone.onboarding.service.model.IndividualApplicant;
import com.yapstone.onboarding.service.model.IndividualOwner;
import com.yapstone.onboarding.service.model.MarketplaceApplicant;
import com.yapstone.onboarding.service.model.MarketplaceProduct;
import com.yapstone.onboarding.service.model.MarketplaceProductPayoutInstrument;
import com.yapstone.onboarding.service.model.MarketplaceProperty;
import com.yapstone.onboarding.service.model.Money;
import com.yapstone.onboarding.service.model.Name;
import com.yapstone.onboarding.service.model.Owner;
import com.yapstone.onboarding.service.model.PayoutInstrument;
import com.yapstone.onboarding.service.model.PayoutProduct;
import com.yapstone.onboarding.service.model.Phone;
import com.yapstone.onboarding.service.model.PriceSetting;
import com.yapstone.onboarding.service.model.Products;
import com.yapstone.onboarding.service.model.Profile;
import com.yapstone.onboarding.service.model.Property;
import com.yapstone.onboarding.service.model.PropertyHistory;
import com.yapstone.onboarding.service.model.PropertyInfo;
import com.yapstone.onboarding.service.model.PropertyOwner;
import com.yapstone.onboarding.service.model.PropertyTracker;
import com.yapstone.onboarding.service.model.Registration;
import com.yapstone.onboarding.service.model.ReservationSetting;
import com.yapstone.onboarding.service.model.SocialNetwork;
import com.yapstone.onboarding.service.model.Status;
import com.yapstone.onboarding.service.model.StatusReason;
import com.yapstone.onboarding.service.model.StaySetting;
import com.yapstone.onboarding.service.model.SuspensionReason;
import com.yapstone.onboarding.service.model.Traveler;

/**
 * Workaround for Mapstruct's inability to handle "standard" {@code Builder} creation patterns until the `1.3.0` release
 * of Mapstruct.
 */
public class BuilderFactory {

    public Action.Builder actionBuilder() {
        return Action.builder();
    }

    public ActionStatus.Builder actionStatusBuilder() {
        return ActionStatus.builder();
    }

    public Address.Builder addressBuilder() {
        return Address.builder();
    }

    public ApplicantConsent.Builder applicantConsentBuilder() {
        return ApplicantConsent.builder();
    }

    public Asset.Builder assetBuilder() {
        return Asset.builder();
    }

    public BankAccount.Builder bankAccountBuilder() {
        return BankAccount.builder();
    }

    public BankAccountData.Builder bankAccountDataBuilder() {
        return BankAccountData.builder();
    }

    public BeneficialOwner.Builder beneficialOwnerBuilder() {
        return BeneficialOwner.builder();
    }

    public BusinessApplicant.Builder businessApplicantBuilder() {
        return BusinessApplicant.builder();
    }

    public BusinessId.Builder businessIdBuilder() {
        return BusinessId.builder();
    }

    public BusinessOwner.Builder businessOwnerBuilder() {
        return BusinessOwner.builder();
    }

    public BusinessProfile.Builder businessProfileBuilder() {
        return BusinessProfile.builder();
    }

    public Consent.Builder consentBuilder() {
        return Consent.builder();
    }

    public Contract.Builder contractBuilder() {
        return Contract.builder();
    }

    public CustomerHistory.Builder customerHistoryBuilder() {
        return CustomerHistory.builder();
    }

    public DeactivateRequest.Builder deactivateRequestBuilder() {
        return DeactivateRequest.builder();
    }

    public DeactivateResponse.Builder deactivateResponseBuilder() {
        return DeactivateResponse.builder();
    }

    public EntityProductStatus.Builder entityProductStatusBuilder() {
        return EntityProductStatus.builder();
    }

    public GovernmentId.Builder governmentIdBuilder() {
        return GovernmentId.builder();
    }

    public IndividualApplicant.Builder individualApplicantBuilder() {
        return IndividualApplicant.builder();
    }

    public IndividualOwner.Builder individualOwnerBuilder() {
        return IndividualOwner.builder();
    }

    public MarketplaceApplicant.Builder marketplaceApplicantBuilder() {
        return MarketplaceApplicant.builder();
    }

    public MarketplaceProduct.Builder marketplaceProductBuilder() {
        return MarketplaceProduct.builder();
    }

    public MarketplaceProperty.Builder marketplacePropertyBuilder() {
        return MarketplaceProperty.builder();
    }

    public Money.Builder moneyBuilder() {
        return Money.builder();
    }

    public Name.Builder nameBuilder() {
        return Name.builder();
    }

    public Owner.Builder ownerBuilder() {
        return Owner.builder();
    }

    public PayoutInstrument.Builder payoutInstrumentBuilder() {
        return PayoutInstrument.builder();
    }

    public MarketplaceProductPayoutInstrument.Builder marketplaceProductPayoutInstrumentBuilder() {
        return MarketplaceProductPayoutInstrument.builder();
    }

    public PayoutProduct.Builder payoutProductBuilder() {
        return PayoutProduct.builder();
    }

    public Phone.Builder phoneBuilder() {
        return Phone.builder();
    }

    public PriceSetting.Builder priceSettingBuilder() {
        return PriceSetting.builder();
    }

    public Products.Builder productsBuilder() {
        return Products.builder();
    }

    public Profile.Builder profileBuilder() {
        return Profile.builder();
    }

    public Property.Builder propertyBuilder() {
        return Property.builder();
    }

    public PropertyHistory.Builder propertyHistoryBuilder() {
        return PropertyHistory.builder();
    }

    public PropertyInfo.Builder propertyInfoBuilder() {
        return PropertyInfo.builder();
    }

    public PropertyOwner.Builder propertyOwnerBuilder() {
        return PropertyOwner.builder();
    }

    public PropertyTracker.Builder propertyTrackerBuilder() {
        return PropertyTracker.builder();
    }

    public ReservationSetting.Builder reservationSettingBuilder() {
        return ReservationSetting.builder();
    }

    public Registration.Builder registrationBuilder() {
        return Registration.builder();
    }

    public SocialNetwork.Builder socialNetworkBuilder() {
        return SocialNetwork.builder();
    }

    public Status.Builder statusBuilder() {
        return Status.builder();
    }

    public StatusReason.Builder statusReasonBuilder() {
        return StatusReason.builder();
    }

    public StaySetting.Builder staySettingBuilder() {
        return StaySetting.builder();
    }

    public SuspensionReason.Builder suspensionReasonBuilder() {
        return SuspensionReason.builder();
    }

    public Traveler.Builder travelerBuilder() {
        return Traveler.builder();
    }


}

  • potential workaround

None as of yet.


(Nicolas Peru) #2

Could you specify which version of the sonarjava analyzer is installed on your server ?


(Aaron Whiteside) #3

We use the Maven plugin to execute the SonarQube analysis, so we don’t install any SonarJava analyzer on our build servers.

I’m not sure if this answers your question or not?

[INFO] --- sonar-maven-plugin:3.5.0.1254:sonar (default-cli) @ onboardingserv ---
[INFO] User cache: /home/ec2-user/.sonar/cache
[INFO] SonarQube version: 7.3.0

(Nicolas Peru) #4

Hi, it does not :slight_smile:
I’m looking for the version of the Java Analyzer that is installed on your sonarqube instance. You can see that in the marketplace of SonarQube if you’re an admin.


(Aaron Whiteside) #5

* **5.7 (build 15470)** installed

I see now that there is an update available, I’ll try again after updating and report back…


(Aaron Whiteside) #6

Still seeing the same problem

[ERROR] Unable to run check class org.sonar.java.se.SymbolicExecutionVisitor -  on file /mnt/ebs1/jenkins/workspace/g-pd_onboardingserv_develop-BHYVP3SWVDSJ6BQG5DGQ4QTAIYTWLMXTBAZDYOZB6QHQCIJ7XE4A/server/service/src/main/java/com/yapstone/onboarding/service/mapper/BuilderFactory.java, To help improve SonarJava, please report this problem to SonarSource : see https://www.sonarqube.org/community/
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.BytecodeMethodVisitor.visitParameterAnnotation(BytecodeMethodVisitor.java:65)
	at org.sonar.java.resolve.BytecodeMethodVisitor.visitTypeAnnotation(BytecodeMethodVisitor.java:76)
	at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1213)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:679)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:391)

With 5.8 (build 15699)installed