# Kotlin class coverage information fails importing due to Line 65535 is out of range in the file

**URL:** <https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522>\
**Category:** SonarQube Server / Community Build\
**Tags:** jacoco, android, kotlin, scanner, coverage\
**Created:** [May 2, 2022, 4:42pm UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522 "2022-05-02T16:42:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicsonvictor](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/vicsonvictor/32/28711_2.png) [@vicsonvictor](https://community.sonarsource.com/u/vicsonvictor)\
**Post date:** [May 2, 2022, 4:42pm UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/1 "2022-05-02T16:42:12Z")

</div>

**Version used:** sonar-scanner-cli-4.7.0.2747  
**Trying to achieve:** Get coverage report generated using jacoco uploaded to sonar cloud using the sonarqube CLI without these out of range errors.  
**Things tried so far:** Using the latest version of sonar and 0.8.8 version of Jacoco and coverage reports are generated everytime we run our CI workflows, so its not stale.

We have approx 10 classes which fail with the same exception as below. The interesting part is all class import failures log with the same ‘Line 65535 is out of range…’ error. Notice the `65535` line number indicated. That sounds kind of fishy. Any clues on why we are seeing this on a handful of classes ?

```auto
ERROR: Cannot import coverage information for file 'uiToolkit/src/main/java/com/shiftkey/uiToolkit/common/ui/compose/Snackbar.kt', coverage data is invalid. Error: {}
java.lang.IllegalStateException: Line 65535 is out of range in the file uiToolkit/src/main/java/com/shiftkey/uiToolkit/common/ui/compose/Snackbar.kt (lines: 63)
	at org.sonar.api.utils.Preconditions.checkState(Preconditions.java:61)
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:67)
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.conditions(DefaultCoverage.java:81)
	at org.sonar.plugins.jacoco.ReportImporter.importCoverage(ReportImporter.java:41)
	at org.sonar.plugins.jacoco.JacocoSensor.importReport(JacocoSensor.java:79)
	at org.sonar.plugins.jacoco.JacocoSensor.importReports(JacocoSensor.java:62)
	at org.sonar.plugins.jacoco.JacocoSensor.execute(JacocoSensor.java:47)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:440)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:436)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:394)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	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.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)

```

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 3, 2022, 8:25am UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/2 "2022-05-03T08:25:19Z")

</div>

Hey there.

That is a super fishy number.

If the XML coverage report is referencing a line 65535 (which you should be able to check) on a file that shouldn’t be that long (and for your sake I hope you aren’t working in files that large!), you probably want to raise an issue on [GitHub - jacoco/jacoco: Java Code Coverage Library](https://github.com/jacoco/jacoco). SonarQube doesn’t generate coverage reports, it only reads them.

---

<div class="post-metadata">

**Author:** ![vicsonvictor](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/vicsonvictor/32/28711_2.png) [@vicsonvictor](https://community.sonarsource.com/u/vicsonvictor)\
**Post date:** [May 4, 2022, 7:33pm UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/3 "2022-05-04T19:33:38Z")

</div>

@Colin You are correct, the classes which report this ridiculous numbers are present in the XML coverage report.

```auto
		<sourcefile name="DisableInteraction.kt">
			<line nr="15" mi="70" ci="0" mb="18" cb="0"/>
			<line nr="16" mi="2" ci="0" mb="2" cb="0"/>
			<line nr="17" mi="14" ci="0" mb="0" cb="0"/>
			<line nr="18" mi="2" ci="0" mb="0" cb="0"/>
			<line nr="19" mi="2" ci="0" mb="0" cb="0"/>
			<line nr="20" mi="4" ci="0" mb="0" cb="0"/>
			<line nr="21" mi="16" ci="0" mb="0" cb="0"/>
			<line nr="22" mi="16" ci="0" mb="0" cb="0"/>
			<line nr="25" mi="18" ci="0" mb="2" cb="0"/>
			<line nr="65535" mi="6" ci="0" mb="2" cb="0"/>
			<counter type="INSTRUCTION" missed="151" covered="0"/>
			<counter type="BRANCH" missed="24" covered="0"/>
			<counter type="LINE" missed="10" covered="0"/>
			<counter type="COMPLEXITY" missed="14" covered="0"/>
			<counter type="METHOD" missed="2" covered="0"/>
			<counter type="CLASS" missed="2" covered="0"/>
		</sourcefile>

```

This particular class has only 25 lines, so this line entry makes no sense:

```auto
<line nr="65535" mi="6" ci="0" mb="2" cb="0"/>

```

I will create an issue on the Jacoco Github repo.

---

<div class="post-metadata">

**Author:** ![vicsonvictor](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/vicsonvictor/32/28711_2.png) [@vicsonvictor](https://community.sonarsource.com/u/vicsonvictor)\
**Post date:** [May 4, 2022, 7:50pm UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/4 "2022-05-04T19:50:04Z")

</div>

@Colin Does the sonar JacocoSensor use the jacoco library indirectly? Wondering if its a different version compared to the one used to generated the reports.

I found the following: [Kotlin: Report shows incorrect number of lines · Issue #1190 · jacoco/jacoco · GitHub](https://github.com/jacoco/jacoco/issues/1190)

And I have confirmed that our reports are generated with the most recent jacoco version(0.8.8)

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 6, 2022, 11:31am UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/5 "2022-05-06T11:31:14Z")

</div>

Hey there.

SonarQube just parses the XML report – it doesn’t depend on the JaCoCo library.

---

<div class="post-metadata">

**Author:** ![anon99500718](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@anon99500718](https://community.sonarsource.com/u/anon99500718)\
**Post date:** [February 9, 2023, 9:26pm UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/6 "2023-02-09T21:26:31Z")

</div>

Did anyone ever resolve this? I’m seeing the same on Jacoco 0.8.8, and I’m also using Compose UI.

---

<div class="post-metadata">

**Author:** ![Margarita\_Nedzelska](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/margarita_nedzelska/32/47493_2.png) [@Margarita\_Nedzelska](https://community.sonarsource.com/u/Margarita_Nedzelska)\
**Post date:** [February 14, 2023, 9:33am UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/7 "2023-02-14T09:33:03Z")

</div>

Hey @anon99500718,

Thanks for your message. If you read this thread carefully, you may notice that the reported problem is in the XML report generated by JaCoCo. Sonar just parses it. So the original problem should be reported and solved on the JaCoCo side.

And there was indeed a reported issue on their side:[Kotlin: Report shows incorrect number of lines · Issue #1190 · jacoco/jacoco · GitHub](https://github.com/jacoco/jacoco/issues/1190)

From the conversation, you can find out that the version specified in gradle build was not taken into consideration, and Gradle used the old version of JaCoCo: [Kotlin: Report shows incorrect number of lines · Issue #1190 · jacoco/jacoco · GitHub](https://github.com/jacoco/jacoco/issues/1190#issuecomment-852667933)  
because of  
[Jacoco HTML report displays wrong "created with" version · Issue #14033 · gradle/gradle · GitHub](https://github.com/gradle/gradle/issues/14033)

So, if you have a proper reproducer, please, report the issue in the right place: jacoco or Gradle. In Sonar we just parse the report, and the line was already incorrect in the report.

Regards,  
Margarita

---

<div class="post-metadata">

**Author:** ![Margarita\_Nedzelska](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/margarita_nedzelska/32/47493_2.png) [@Margarita\_Nedzelska](https://community.sonarsource.com/u/Margarita_Nedzelska)\
**Post date:** [February 14, 2023, 9:33am UTC](https://community.sonarsource.com/t/kotlin-class-coverage-information-fails-importing-due-to-line-65535-is-out-of-range-in-the-file/62522/8 "2023-02-14T09:33:13Z")

</div>

Closed on February 14, 2023, 9:33am UTC


