Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8343882

BasicAnnoTests doesn't handle multiple annotations at the same position

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • None
    • tools
    • master

      Thomas Fitzsimmons noticed this issue in https://github.com/openjdk/jdk17u-dev/pull/2955

      BasicAnnoTests uses @Test annotations for test cases, which a 'posn' representation the expected location of an annotation to check for. Some tests have multiple @Test annotations with the same position:

              @Test(posn=0, annoType = TA.class, expect = "70")
              @Test(posn=0, annoType = TB.class, expect = "71")
              @TA(70) @TB(71) String f;

      The tests creates a map indexed by posn, so if multiple annotations have the same posn only one of them is processed: https://github.com/openjdk/jdk/blame/325a2c3f76a45248e6f8baa63477db15e55be705/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java#L174-L177

      The following change should cause the test to fail, but doesn't, because the modified @Test annotation is not being processed due to this bug:

      $ diff --git a/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java b/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java
      index 904e4e78cad..01206faeb6d 100644
      --- a/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java
      +++ b/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java
      @@ -697,7 +697,7 @@ class Inner8<@TA(50) T> {
           <T> void m60(@TA(60) @TB(61) String t) { }

           class Inner70<T> {
      - @Test(posn=0, annoType = TA.class, expect = "70")
      + @Test(posn=0, annoType = TA.class, expect = "99")
               @Test(posn=0, annoType = TB.class, expect = "71")
               @TA(70) @TB(71) String f;
           }

      $ make test TEST="jtreg:test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java"
      ...
      Passed: tools/javac/processing/model/type/BasicAnnoTests.java

            cushon Liam Miller-Cushon
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: