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

A module declaration is not allowed to be a target of an annotation that lacks an @Target meta-annotation

    Details

    • Subcomponent:
    • Resolved In Build:
      b30
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Copied from java.lang.annotation.Target's API documentation:

        > If an @Target meta-annotation is not present on an annotation type T, then an annotation of type T may be written as a modifier for any declaration except a type parameter declaration.

        As "module declarations" are not listed in the exception above, the following minimal modular example should compile:

          `A.java`
          | package test;
          | public @interface A {}

          `module-info.java`
          | @test.A
          | module test {}

        The error message reads:

        javac -d classes --module-source-path . --module test

          | ./test/module-info.java:1: error: annotation type not applicable to this kind of declaration
          | @test.A
          | ^
          | 1 error

        Find the _not-compiling_ source code of the example here: https://github.com/sormuras/sandbox/tree/master/java-annotation-on-module

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jfranck Joel Borggrén-Franck
                  Reporter:
                  cstein Christian Stein
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: