GeezerVison is showing github.com — Add filter for bytecode generated by Kotlin serialization compiler plugin by Godin · Pull Request #1885 · jacoco/jacoco
Conversation
Godin
commented
Apr 29, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for looking into the issue.
I was thinking if we could somehow prevent such regression as it's tough thinking in advance of other possible compiler plugins and their combinations. On the other hand, serialization plugin is a pretty big one and we now have a test for it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
nextIs(Opcodes.ARETURN);
|
|
|
return cursor != null
|
|
|
&& getStaticInstruction.name.equals("INSTANCE")
|
|
|
&& (lineNumberInstruction instanceof LineNumberNode)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly we can't use pattern matching on instanceOf here (Java 14) :(
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks a lot @Godin for taking care of this MR as Kotlinx Serialization caused a lot of troubles for me with synthetic methods and coverage.
I use a snapshot Jacoco version and today it broke for my project perhaps due to this commit (or another about ASM update). Please take a look if it's something relevant for a fix:
...
Caused by: java.io.IOException: Error while analyzing BillingAddressFieldType$Companion.class with JaCoCo 0.8.14.202510071157/0981128.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:163)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:135)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:158)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:195)
at org.jacoco.ant.ReportTask.createBundle(ReportTask.java:573)
at org.jacoco.ant.ReportTask.createReport(ReportTask.java:545)
at org.jacoco.ant.ReportTask.execute(ReportTask.java:496)
... 155 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.objectweb.asm.tree.AbstractInsnNode.getPrevious()" because "this.cursor" is null
at org.jacoco.core.internal.analysis.filter.KotlinSerializableFilter$Matcher.match(KotlinSerializableFilter.java:79)
at org.jacoco.core.internal.analysis.filter.KotlinSerializableFilter.filter(KotlinSerializableFilter.java:44)
at org.jacoco.core.internal.analysis.filter.FilterSet.filter(FilterSet.java:31)
at org.jacoco.core.internal.analysis.filter.Filters$1.filter(Filters.java:45)
at org.jacoco.core.internal.analysis.ClassAnalyzer.addMethodCoverage(ClassAnalyzer.java:131)
at org.jacoco.core.internal.analysis.ClassAnalyzer.access$100(ClassAnalyzer.java:38)
at org.jacoco.core.internal.analysis.ClassAnalyzer$1.accept(ClassAnalyzer.java:115)
at org.jacoco.core.internal.flow.ClassProbesAdapter$2.visitEnd(ClassProbesAdapter.java:91)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1516)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:745)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:425)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:117)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:133)
The class it complains about BillingAddressFieldType$Companion.class has an empty companion object declared without any body/fields (just companion object).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@ajeihala first of all thank you for testing snapshot version and for the report ❤
while there is already another report #1969 with the same stack trace
your example is different and
empty companion object declared without any body/fields (just companion object)
like
@Serializable
class EmptyCompanion {
companion object
}
does not seem to be enough to trigger NPE, so could you please provide source code of your BillingAddressFieldType and/or class files BillingAddressFieldType.class and BillingAddressFieldType$Companion.class entirely to make sure that we won't miss some corner-case again?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Perhaps the enum class makes the difference.
With this
@Serializable
enum class EmptyCompanion {
@SerialName("TEST")
TEST;
companion object
}
it fails too with Error while analyzing EmptyCompanion$Companion.class with JaCoCo 0.8.14.202510071157/0981128 and the same Cannot invoke "org.objectweb.asm.tree.AbstractInsnNode.getPrevious()" because "this.cursor" is null.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@ajeihala thanks!
Perhaps the enum class makes the difference.
yes - it is
fix for #1969 will handle both,
so we will communicate updates in it but not here - you can subscribe to it
|
ajeihala reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Oct 8, 2025
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|