Skip to content

Conversation

@Godin
Copy link
Member

@Godin Godin commented Jun 5, 2023

Before this change for the following Example.java

record Example(int x, int y) {

  static void example_instanceof(Object o) {
    if (o instanceof Example(int x, int y)) {
      System.out.println(x + ", " + y);
    }
  }

  static void example_switch(Object o) {
    switch (o) {
      case Example(int x, int y) -> System.out.println(x + ", " + y);
      default -> System.out.println();
    }
  }

  public static void main(String[] args) {
    example_instanceof(new Object());
    example_instanceof(new Example(1, 2));
    example_switch(new Object());
    example_switch(new Example(1, 2));
  }
}

using

openjdk version "21-ea" 2023-09-19
OpenJDK Runtime Environment (build 21-ea+25-2212)
OpenJDK 64-Bit Server VM (build 21-ea+25-2212, mixed mode, sharing)

execution of

javac Example.java -d classes
java -javaagent:jacocoagent.jar -cp classes Example
java -jar jacococli.jar report jacoco.exec --classfiles classes --sourcefiles . --html report

produces

before before

and after this change

after after

@Godin Godin force-pushed the RecordPatternFilter branch from 727139b to bc71921 Compare June 5, 2023 14:35
@Godin Godin marked this pull request as ready for review June 5, 2023 15:18
@Godin Godin requested a review from marchof June 5, 2023 15:18
@marchof marchof merged commit e437b64 into jacoco:master Jun 5, 2023
@marchof
Copy link
Member

marchof commented Jun 5, 2023

@Godin While reviewing this PR I noticed that record pattern matching and switch pattern matching has been finalized in Java 21. Shouldn't we move it to a new project org.jacoco.text.validation.java21?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants