Skip to content

ASM 8.0 does not preserve empty Record attribute in absence of record components #1037

@Godin

Description

@Godin

For following Example.java

record Example() {
    public static void main(String[] args) {
        System.out.println(Example.class.isRecord());
        System.out.println(Example.class.getRecordComponents().length);
    }
}

execution of

javac --release 14 --enable-preview Example.java
java -javaagent:jacocoagent.jar --enable-preview Example

using JaCoCo 0.8.5 prints

true
0

while using JaCoCo 0.8.6-SNAPSHOT

false
Exception in thread "main" java.lang.NullPointerException
        at Example.main(Example.java:4)

Class file instrumented by 0.8.5 contains empty Record attribute, while class file instrumented by 0.8.6-SNAPSHOT does not - see output of

java -jar jacoco-0.8.5/lib/jacococli.jar instrument Example.class --dest before
java -jar jacoco-0.8.6-20200329.124051-45/lib/jacococli.jar instrument Example.class --dest after
javap -v -p before/Example.class > before.txt
javap -v -p after/Example.class > after.txt
diff before.txt after.txt

This regression was introduced by the upgrade of ASM to 8.0 (#1032) - see https://mail.ow2.org/wws/arc/asm/2020-03/msg00001.html

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions