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

XMLWordPrintable

    • b30
    • generic
    • generic

        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

              jfranck Joel Borggrén-Franck (Inactive)
              cstein Christian Stein
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: