Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SMAP generated by Kotlin 1.5 compiler (Support JSR-45 spec) #1155

Closed
max-kammerer opened this issue Feb 17, 2021 · 19 comments · Fixed by #1164
Closed

Support SMAP generated by Kotlin 1.5 compiler (Support JSR-45 spec) #1155

max-kammerer opened this issue Feb 17, 2021 · 19 comments · Fixed by #1164
Assignees
Labels
Milestone

Comments

@max-kammerer
Copy link

Prior version 1.5 Kotlin compiler violate JSR-45 specification in case of several stratum presence that was fixed in 1.5. There was a problem with *E presence between stratums which according to specification should be presented only at the end of SMAP (more details could be found in https://youtrack.jetbrains.com/issue/KT-37704).

Now proper SMAP output breaks JaCoCo parser with Unexpected SMAP line: *S KotlinDebug exception.
Repro project could be found in https://youtrack.jetbrains.com/issue/KT-44757

@max-kammerer max-kammerer added the type: bug 🐛 Something isn't working label Feb 17, 2021
@Godin Godin self-assigned this Feb 17, 2021
@Godin
Copy link
Member

Godin commented Feb 17, 2021

Reduced reproducer:

for Example.kt

inline fun f() {}
fun g() = f()

execution of

./kotlin-1.4.30/bin/kotlinc -language-version 1.5 Example.kt

java -jar ./jacoco-0.8.6/lib/jacococli.jar classinfo ExampleKt.class

fails with

Exception in thread "main" java.io.IOException: Error while analyzing ExampleKt.class.
Caused by: java.lang.IllegalStateException: Unexpected SMAP line: *S KotlinDebug

@Godin Godin added this to the 0.8.7 milestone Feb 21, 2021
@Godin Godin added this to Candidates in Current work items via automation Feb 21, 2021
@maranathaaa

This comment has been minimized.

@Godin

This comment has been minimized.

@Godin Godin added this to To Do in Filtering via automation Mar 14, 2021
@Godin Godin moved this from Candidates to Implementation in Current work items Mar 15, 2021
Filtering automation moved this from To Do to Done Mar 16, 2021
Current work items automation moved this from Implementation to Done Mar 16, 2021
alwa pushed a commit to Sundbybergs-IT/Crom-Fortune that referenced this issue May 1, 2021
@michaelbrewer
Copy link

When will this be fixed for Gradle and Kotlin 1.5?

@overfullstack
Copy link

This issue still exists. When can we expect a fix?

@marchof
Copy link
Member

marchof commented May 2, 2021

Just check the FAQ:

When will feature X be released?

JaCoCo is maintained by volunteers in their free time. Since we cannot guarantee free capacity, we do not commit to particular release dates. Typically, you can expect a couple of releases every year.

In the change log, you can see all features that have been implemented in master branch and will be available with the next release. And in the meantime you can test latest build of master branch (Maven SNAPSHOT) and provide feedback to us.

@marcust
Copy link

marcust commented May 2, 2021

It is fixed in the next version, so you have to wait until 0.8.7 is released. In urgent cases you can start using the 0.8.7-SNAPSHOT available via Snapshot Builds

@Godin
Copy link
Member

Godin commented May 5, 2021

@laalto

at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.getFirstGeneratedLineNumber(KotlinInlineFilter.java:98)

you can't have such stack trace when you really use JaCoCo 0.8.7, because in 0.8.7 throw is not located on line 98, but on line 102:

https://github.com/jacoco/jacoco/blob/v0.8.7/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinInlineFilter.java#L102

@laalto
Copy link

laalto commented May 5, 2021

Yeah, that's interesting. Using the jacoco gradle plugin with classpath "org.jacoco:org.jacoco.core:0.8.7" in project-level build.gradle. Digging deeper

@Godin
Copy link
Member

Godin commented May 5, 2021

Using the jacoco gradle plugin with classpath "org.jacoco:org.jacoco.core:0.8.7"

Regarding https://docs.gradle.org/current/userguide/jacoco_plugin.html
please see #1164 (comment) that states the same as in mentioned above Gradle documentation:
jacoco.toolVersion can be set to non-default value to use specific version including 0.8.7

For the other Gradle plugins, please refer to their documentation.

@laalto
Copy link

laalto commented May 5, 2021

Thanks for the quick responses. Looks like the project had some legacy to be updated in its jacoco setup. jacoco.toolVersion didn't work though, needed to use a construct like in https://stackoverflow.com/questions/63479850/jacoco-gradle-plugin-ignoring-version to force 0.8.7 to be used and to get migration to kotlin 1.5.0 proceed further.

sschuberth added a commit to oss-review-toolkit/ort that referenced this issue May 6, 2021
This is a prerequisite for upgrading to Kotlin 1.5, see
jacoco/jacoco#1155.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue May 6, 2021
This is a prerequisite for upgrading to Kotlin 1.5, see
jacoco/jacoco#1155.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
centic9 pushed a commit to jenkinsci/jacoco-plugin that referenced this issue May 7, 2021
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue May 14, 2021
This is a prerequisite for upgrading to Kotlin 1.5, see
jacoco/jacoco#1155.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
@hbb20
Copy link

hbb20 commented May 18, 2021

Thanks for the quick responses. Looks like the project had some legacy to be updated in its jacoco setup. jacoco.toolVersion didn't work though, needed to use a construct like in https://stackoverflow.com/questions/63479850/jacoco-gradle-plugin-ignoring-version to force 0.8.7 to be used and to get migration to kotlin 1.5.0 proceed further.

@laalto Even that is not working for me.. still seeing error on line 98 means it's not using 0.8.7. Any ideas why or what else can I try?

sschuberth added a commit to oss-review-toolkit/ort that referenced this issue May 19, 2021
This is a prerequisite for upgrading to Kotlin 1.5, see
jacoco/jacoco#1155.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
oowekyala added a commit to lf-lang/lingua-franca that referenced this issue May 23, 2021
jacoco/jacoco#1155

Was fixed in Jacoco 0.8.7. Wrong syntax in
gradle file made the jacoco version be defaulted.
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue May 28, 2021
This is a prerequisite for upgrading to Kotlin 1.5, see [1].

The change can be reverted when upgrading to Gradle 7.1 which will use
Jacoco 0.8.7 by default, see [2].

[1] jacoco/jacoco#1155
[2] gradle/gradle#17077 (comment)

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue May 31, 2021
This is a prerequisite for upgrading to Kotlin 1.5, see [1].

The change can be reverted when upgrading to Gradle 7.1 which will use
Jacoco 0.8.7 by default, see [2].

[1] jacoco/jacoco#1155
[2] gradle/gradle#17077 (comment)

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue May 31, 2021
This is a prerequisite for upgrading to Kotlin 1.5, see [1].

The change can be reverted when upgrading to Gradle 7.1 which will use
Jacoco 0.8.7 by default, see [2].

[1] jacoco/jacoco#1155
[2] gradle/gradle#17077 (comment)

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
yvolk added a commit to andstatus/andstatus that referenced this issue Jun 3, 2021
ParaskP7 added a commit to ParaskP7/sample-code-movies that referenced this issue Jun 6, 2021
This change is actually necessary in order for Jacoco to work with
Kotlin version 1.5.0 and above.

For more info see: jacoco/jacoco#1155
@mohamed-khaled-hsn
Copy link

Thanks for the quick responses. Looks like the project had some legacy to be updated in its jacoco setup. jacoco.toolVersion didn't work though, needed to use a construct like in https://stackoverflow.com/questions/63479850/jacoco-gradle-plugin-ignoring-version to force 0.8.7 to be used and to get migration to kotlin 1.5.0 proceed further.

@laalto Even that is not working for me.. still seeing error on line 98 means it's not using 0.8.7. Any ideas why or what else can I try?

This worked in my case:
If you have a multi-module project, you can specify jacoco toolVersion in allProjects

allprojects {
    jacoco {
        toolVersion = "0.8.7"
    }
    //..
}

@Maksym-Motornyi
Copy link

To force use 0.8.7 version just add this to the project level gradle file:

subprojects {
    configurations.all {
        resolutionStrategy {
            eachDependency { details ->
                if ('org.jacoco' == details.requested.group) {
                    details.useVersion "0.8.7"
                }
            }
        }
    }
}

@xghita
Copy link

xghita commented Jun 11, 2021

@Maksym-Motornyi Still got the error on line 98

java.lang.IllegalStateException: Unexpected SMAP line: *S KotlinDebug
	at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.getFirstGeneratedLineNumber(KotlinInlineFilter.java:98)

which by @Godin comment (#1155 (comment) ) means the project is still not using 0.8.7 version.

In my case is working fine when I run tests local with Android studio, but got the issue on a remote Jenkins machine.

@NikolayMetchev
Copy link

Have you updated the Jenkins Jacoco plugin https://plugins.jenkins.io/jacoco/?

@xghita
Copy link

xghita commented Jun 11, 2021

Have you updated the Jenkins Jacoco plugin https://plugins.jenkins.io/jacoco/?

thank you! updating to 3.2.0 has fixed it.

@jacoco jacoco locked as resolved and limited conversation to collaborators Jun 11, 2021
denniseffing pushed a commit to codecentric/habitcentric that referenced this issue Jan 18, 2022
To fix various errors and warnings the following was done.

report:
- upgraded kotlin & gradle kotlin plugins
- upgraded openapi generator plugin
- upgrade jacoco to fix: jacoco/jacoco#1155

habit, track and gateway:
- upgrade spotless plugin

gateway:
- upgrade lombock plugin

habit:
- upgrade liquibase plugin

track:
- upgrade flyway plugin
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Filtering
  
Done
Development

Successfully merging a pull request may close this issue.