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

RoundEnvironment.getElementsAnnotatedWith(anno) returns null, no empty set

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b79
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      The regression test test/tools/javac/api/TestTrees.java (to be put back shortly) demonstrates that getElementsAnnotatedWith(anno) is returning null, whereas the spec clearly says "empty set if there are none".

      For the record here, here is the body of my annotation processor, and after it is a sample of the output:

      ----- Anno Processor ----------------------------------
          public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
      Trees trees = Trees.instance(processingEnv);
      messager = processingEnv.getMessager();

      for (Element e: rEnv.getSpecifiedTypeElements()) {
      testElement(trees, e);
      }

      for (TypeElement anno: annos) {
      Set<? extends Element> elts = rEnv.getElementsAnnotatedWith(anno);
      System.err.println("anno: " + anno);
      System.err.println("elts: " + elts);
      if (elts != null) { // bug, should return empty set
      for (Element e: rEnv.getElementsAnnotatedWith(anno))
      testElement(trees, e);
      }
      }

      return true;
          }

      ----- Output: -----------------------------

      anno: java.lang.annotation.Retention
      elts: null
      anno: javax.annotation.processing.SupportedAnnotationTypes
      elts: null
      anno: Anno
      elts: null

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              jjg Jonathan Gibbons
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: