Skip to content

exhaustive switch expression is not fully covered #1571

@eortega-pjr

Description

@eortega-pjr

I apologize if the terminology is incorrect. I wasn't getting full coverage on our fully-defined and exercised switch-expressions after upgrading to jacoco-8.11.0.

I extended the original example here: #1472


  • JaCoCo version: 0.8.11.202310140853
  • Operating system: Linux
  • Tool integration: none/javac
java version "21.0.1" 2023-10-17 LTS
Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)
  • Complete executable reproducer:
enum Example {
    A, B;

    static void example(Example e) {
        switch (e) {
            case A -> {
                int i = 4;
            }
            case B -> {
                int i = 4;
            }
        }
    }

    public static void main(String[] args) {
        example(A);
        example(B);
    }
}
  • Steps: (what exactly are you doing with the above reproducer?)
javac Example.java -d classes
java -javaagent:jacocoagent.jar -cp classes Example
java -jar jacococli.jar report jacoco.exec --classfiles classes --sourcefiles . --html report

Expected behaviour

Full branch coverage

Actual behaviour

2024-01-24-163922_565x578_scrot

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions