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

Repeating annotations: No Target on container annotation with all targets on base annotation gives compiler error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 8
    • tools
    • None
    • b84
    • Verified

    Description

      Test case: Foo has @Target with all ElementType enum constants and FooContainer does not have @Target.

      Based on this rule, the above test case should compile:
      If an annotation is not meta-annotated with @Target, then the compiler treats the annotation as if it is meta-annotated with all of the ElementType enum constants that appear in Java 7: ANNOTATION_TYPE, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, and TYPE

      Expected: code should compile fine.
      Actual behavior: Compiler error:
      NoTargetonContainer.java:9: error: target of container annotation FooContainer is not a subset of target of repeated annotation Foo
      @ContainedBy(FooContainer.class)
      ^
      1 error

      Test src code attached.

      Attachments

        Issue Links

          Activity

            People

              jfranck Joel Borggrén-Franck (Inactive)
              sogoel Sonali Goel (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: